Markdown reader: Handle c++
and objective-c
as language identifiers
in github-style fenced blocks. Closes #1318. Note: This is special-case handling of these two cases. It would be good to do something more systematic.
This commit is contained in:
parent
2d90803b7c
commit
e3ddc371de
1 changed files with 8 additions and 1 deletions
|
@ -618,12 +618,19 @@ codeBlockFenced = try $ do
|
|||
skipMany spaceChar
|
||||
attr <- option ([],[],[]) $
|
||||
try (guardEnabled Ext_fenced_code_attributes >> attributes)
|
||||
<|> ((\x -> ("",[x],[])) <$> identifier)
|
||||
<|> ((\x -> ("",[toLanguageId x],[])) <$> many1 nonspaceChar)
|
||||
blankline
|
||||
contents <- manyTill anyLine (blockDelimiter (== c) (Just size))
|
||||
blanklines
|
||||
return $ return $ B.codeBlockWith attr $ intercalate "\n" contents
|
||||
|
||||
-- correctly handle github language identifiers
|
||||
toLanguageId :: String -> String
|
||||
toLanguageId = map toLower . go
|
||||
where go "c++" = "cpp"
|
||||
go "objective-c" = "objectivec"
|
||||
go x = x
|
||||
|
||||
codeBlockIndented :: MarkdownParser (F Blocks)
|
||||
codeBlockIndented = do
|
||||
contents <- many1 (indentedLine <|>
|
||||
|
|
Loading…
Add table
Reference in a new issue