mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-26 09:25:48 +00:00
Org reader: Fix parsing of blank lines within blocks
Blank lines were parsed as two newlines instead of just one. Thanks to Xiao Hanyu (@xiaohanyu) for pointing this out.
This commit is contained in:
@@ -357,12 +357,8 @@ rawBlockContent :: BlockProperties -> OrgParser String
|
||||
rawBlockContent (indent, blockType) = try $
|
||||
unlines . map commaEscaped <$> manyTill indentedLine blockEnder
|
||||
where
|
||||
indentedLine = try $
|
||||
choice [ blankline *> pure "\n"
|
||||
, indentWith indent *> anyLine
|
||||
]
|
||||
blockEnder = try $
|
||||
indentWith indent *> stringAnyCase ("#+end_" <> blockType)
|
||||
indentedLine = try $ ("" <$ blankline) <|> (indentWith indent *> anyLine)
|
||||
blockEnder = try $ indentWith indent *> stringAnyCase ("#+end_" <> blockType)
|
||||
|
||||
parsedBlockContent :: BlockProperties -> OrgParser (F Blocks)
|
||||
parsedBlockContent blkProps = try $ do
|
||||
|
||||
@@ -920,5 +920,14 @@ tests =
|
||||
(unlines [ "fmap id = id"
|
||||
, "fmap (p . q) = (fmap p) . (fmap q)"
|
||||
])))
|
||||
|
||||
, "Convert blank lines in blocks to single newlines" =:
|
||||
unlines [ "#+begin_html"
|
||||
, ""
|
||||
, "<span>boring</span>"
|
||||
, ""
|
||||
, "#+end_html"
|
||||
] =?>
|
||||
rawBlock "html" "\n<span>boring</span>\n\n"
|
||||
]
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user