diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-11-09 11:34:50 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-11-09 23:22:44 -0500 |
commit | 1592d3882142bbb938608e04d179f148453d93bb (patch) | |
tree | 9e41307dd56f64f26470e0eea0c4ffd04934de7f /src/Text/Pandoc | |
parent | f72d7636557b01812dcd13826b7697c3ceb20a76 (diff) | |
download | pandoc-1592d3882142bbb938608e04d179f148453d93bb.tar.gz |
Allow fenced code blocks to be indented 1-3 spaces.
This brings our handling of them into alignment with
CommonMark's.
Closes #??.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 8fc92f7e8..8977517c1 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -623,8 +623,9 @@ indentedLine = indentSpaces >> anyLineNewline blockDelimiter :: PandocMonad m => (Char -> Bool) -> Maybe Int - -> ParserT [Char] st m Int + -> ParserT [Char] ParserState m Int blockDelimiter f len = try $ do + skipNonindentSpaces c <- lookAhead (satisfy f) case len of Just l -> count l (char c) >> many (char c) >> return l @@ -689,6 +690,8 @@ rawAttribute = do codeBlockFenced :: PandocMonad m => MarkdownParser m (F Blocks) codeBlockFenced = try $ do + indentchars <- nonindentSpaces + let indentLevel = length indentchars c <- try (guardEnabled Ext_fenced_code_blocks >> lookAhead (char '~')) <|> (guardEnabled Ext_backtick_code_blocks >> lookAhead (char '`')) size <- blockDelimiter (== c) Nothing @@ -701,7 +704,8 @@ codeBlockFenced = try $ do <|> ((\x -> ("",[toLanguageId x],[])) <$> many1 nonspaceChar))) blankline contents <- intercalate "\n" <$> - manyTill anyLine (blockDelimiter (== c) (Just size)) + manyTill (gobbleAtMostSpaces indentLevel >> anyLine) + (blockDelimiter (== c) (Just size)) blanklines return $ return $ case rawattr of |