diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 4eb17c16b..0708690d4 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -355,7 +355,6 @@ parseBlocks = mconcat <$> manyTill block eof block :: MarkdownParser (F Blocks) block = choice [ codeBlockFenced - , codeBlockBackticks , guardEnabled Ext_latex_macros *> (mempty <$ macro) , header , lhsCodeBlock @@ -520,27 +519,18 @@ keyValAttr = try $ do codeBlockFenced :: MarkdownParser (F Blocks) codeBlockFenced = try $ do - guardEnabled Ext_fenced_code_blocks - size <- blockDelimiter (=='~') Nothing + c <- try (guardEnabled Ext_fenced_code_blocks >> lookAhead (char '~')) + <|> (guardEnabled Ext_backtick_code_blocks >> lookAhead (char '`')) + size <- blockDelimiter (== c) Nothing skipMany spaceChar attr <- option ([],[],[]) $ - guardEnabled Ext_fenced_code_attributes >> attributes + try (guardEnabled Ext_fenced_code_attributes >> attributes) + <|> ((\x -> ("",[x],[])) <$> identifier) blankline - contents <- manyTill anyLine (blockDelimiter (=='~') (Just size)) + contents <- manyTill anyLine (blockDelimiter (== c) (Just size)) blanklines return $ return $ B.codeBlockWith attr $ intercalate "\n" contents -codeBlockBackticks :: MarkdownParser (F Blocks) -codeBlockBackticks = try $ do - guardEnabled Ext_backtick_code_blocks - blockDelimiter (=='`') (Just 3) - skipMany spaceChar - cls <- many1 alphaNum - blankline - contents <- manyTill anyLine $ blockDelimiter (=='`') (Just 3) - blanklines - return $ return $ B.codeBlockWith ("",[cls],[]) $ intercalate "\n" contents - codeBlockIndented :: MarkdownParser (F Blocks) codeBlockIndented = do contents <- many1 (indentedLine <|> |