diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2013-01-23 13:07:07 -0800 | 
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2013-01-23 13:21:53 -0800 | 
| commit | 7a0062a8d5d6f3ea8b754b23eb6af6f8e07a8102 (patch) | |
| tree | 4fd62d4e05663c0f13f0e5d3a76aaf567c9ed9f9 /src/Text | |
| parent | 7cd5239d609fae0cfa34ac869b72c4badffb17fe (diff) | |
| download | pandoc-7a0062a8d5d6f3ea8b754b23eb6af6f8e07a8102.tar.gz | |
Fixed regressions in fenced code blocks.
*   Tilde code fences can again take bare language.
    So
        ~~~ haskell
    is okay, not just
        ~~~ {.haskell}
*   Backtick code blocks can take the bracketed attributes.
*   Backtick code blocks don't require a language.
*   Consolidated code for the two kinds of fenced code blocks.
Closes #722.
Diffstat (limited to 'src/Text')
| -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 <|> | 
