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:
parent
757c4f68f3
commit
07694b3018
2 changed files with 11 additions and 6 deletions
|
@ -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"
|
||||
]
|
||||
]
|
||||
|
|
Loading…
Add table
Reference in a new issue