git.iko.soy/typeable/pandoc
on master help sign in
Allow empty lines when parsing line blocks

Line blocks are allowed to contain empty lines and should be parsed as a single block in that case. Previously an empty (line block) line would have terminated parsing of the line block element.

commit3e60ed9c039d90fc0c9001cd0a123ed8bb38eac7 authorAlbert Krewinkel <albert@zeitkraut.de> dateThu 13 Oct 2016, 08:46 (10 years ago) parentc9460e7
1 file changed+5−2
src/Text/Pandoc/Parsing.hs+5−2
src/Text/Pandoc/Parsing.hs+5−2
@@ -718,11 +718,14 @@ lineBlockLine = try $ do
718718 continuations <- many (try $ char ' ' >> anyLine)
719719 return $ white ++ unwords (line : continuations)
720720
721+blankLineBlockLine :: Stream [Char] m Char => ParserT [Char] st m Char
722+blankLineBlockLine = try (char '|' >> blankline)
723+
721724-- | Parses an RST-style line block and returns a list of strings.
722725lineBlockLines :: Stream [Char] m Char => ParserT [Char] st m [String]
723726lineBlockLines = try $ do
724− lines' <- many1 lineBlockLine
725− skipMany1 $ blankline <|> try (char '|' >> blankline)
727+ lines' <- many1 (lineBlockLine <|> ((:[]) <$> blankLineBlockLine))
728+ skipMany1 $ blankline <|> blankLineBlockLine
726729 return lines'
727730
728731-- | Parse a table using 'headerParser', 'rowParser',