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:
Albert Krewinkel 2014-05-09 18:23:23 +02:00
parent 757c4f68f3
commit 07694b3018
2 changed files with 11 additions and 6 deletions

View file

@ -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

View file

@ -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"
]
]