git.iko.soy/typeable/pandoc
on master help sign in
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.

commit07694b30184bcf2ed0e2998016df394f47a1996f authorAlbert Krewinkel <tarleb@moltkeplatz.de> dateFri 9 May 2014, 18:23 (12 years ago) parent757c4f6
2 files changed+11−6
src/Text/Pandoc/Readers/Org.hs+2−6 tests/Tests/Readers/Org.hs+9
src/Text/Pandoc/Readers/Org.hs+2−6
@@ -357,12 +357,8 @@ rawBlockContent :: BlockProperties -> OrgParser String
357357rawBlockContent (indent, blockType) = try $
358358 unlines . map commaEscaped <$> manyTill indentedLine blockEnder
359359 where
360− indentedLine = try $
361− choice [ blankline *> pure "\n"
362− , indentWith indent *> anyLine
363− ]
364− blockEnder = try $
365− indentWith indent *> stringAnyCase ("#+end_" <> blockType)
360+ indentedLine = try $ ("" <$ blankline) <|> (indentWith indent *> anyLine)
361+ blockEnder = try $ indentWith indent *> stringAnyCase ("#+end_" <> blockType)
366362
367363parsedBlockContent :: BlockProperties -> OrgParser (F Blocks)
368364parsedBlockContent blkProps = try $ do
tests/Tests/Readers/Org.hs+9
@@ -920,5 +920,14 @@ tests =
920920 (unlines [ "fmap id = id"
921921 , "fmap (p . q) = (fmap p) . (fmap q)"
922922 ])))
923+
924+ , "Convert blank lines in blocks to single newlines" =:
925+ unlines [ "#+begin_html"
926+ , ""
927+ , "<span>boring</span>"
928+ , ""
929+ , "#+end_html"
930+ ] =?>
931+ rawBlock "html" "\n<span>boring</span>\n\n"
923932 ]
924933 ]