git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Handle `c++` and `objective-c` as language identifiers
e3ddc37John MacFarlane
src/Text/Pandoc/Readers/Markdown.hs+8−1
@@ -618,12 +618,19 @@ codeBlockFenced = try $ do
618 skipMany spaceChar
618 skipMany spaceChar
619 attr <- option ([],[],[]) $
619 attr <- option ([],[],[]) $
620 try (guardEnabled Ext_fenced_code_attributes >> attributes)
620 try (guardEnabled Ext_fenced_code_attributes >> attributes)
621− <|> ((\x -> ("",[x],[])) <$> identifier)
621+ <|> ((\x -> ("",[toLanguageId x],[])) <$> many1 nonspaceChar)
622 blankline
622 blankline
623 contents <- manyTill anyLine (blockDelimiter (== c) (Just size))
623 contents <- manyTill anyLine (blockDelimiter (== c) (Just size))
624 blanklines
624 blanklines
625 return $ return $ B.codeBlockWith attr $ intercalate "\n" contents
625 return $ return $ B.codeBlockWith attr $ intercalate "\n" contents
626
626
627+-- correctly handle github language identifiers
628+toLanguageId :: String -> String
629+toLanguageId = map toLower . go
630+ where go "c++" = "cpp"
631+ go "objective-c" = "objectivec"
632+ go x = x
633+
627codeBlockIndented :: MarkdownParser (F Blocks)
634codeBlockIndented :: MarkdownParser (F Blocks)
628codeBlockIndented = do
635codeBlockIndented = do
629 contents <- many1 (indentedLine <|>
636 contents <- many1 (indentedLine <|>