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:
John MacFarlane 2014-05-27 12:44:39 -07:00
parent 2d90803b7c
commit e3ddc371de

View file

@ -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 <|>