aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-05-27 12:44:39 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-05-27 12:44:39 -0700
commite3ddc371dee9630dae71d61a69088b06cea8e909 (patch)
tree54b0c4c6f582958b29e9996898715b9a4cb2f071
parent2d90803b7ce586c4c882b907f00f574e3432f3c1 (diff)
downloadpandoc-e3ddc371dee9630dae71d61a69088b06cea8e909.tar.gz
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.
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 5129bc2e3..caa938ed6 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -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 <|>