diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
index c05ac92d0..0f218d43f 100644
--- a/src/Text/Pandoc/Readers/Org.hs
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -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
diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs
index a78e8861f..87b0d0c90 100644
--- a/tests/Tests/Readers/Org.hs
+++ b/tests/Tests/Readers/Org.hs
@@ -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"
+ , ""
+ , "boring"
+ , ""
+ , "#+end_html"
+ ] =?>
+ rawBlock "html" "\nboring\n\n"
]
]