git.iko.soy/typeable/pandoc
on master help sign in
Make sure verse blocks can contain empty lines

The previous verse parsing code made the faulty assumption that empty strings are valid (and empty) inlines. This isn't the case, so lines are changed to contain at least a newline. It would generally be nicer and faster to keep the newlines while splitting the string. However, this would require more code, which seems unjustified for a simple (and fairly rare) block as *verse*. This fixes #2402.

commit8007dd97b5d403f54c218a178573a818ab80c667 authorAlbert Krewinkel <albert@zeitkraut.de> dateSat 19 Sep 2015, 21:54 (11 years ago) parent4d49f76
2 files changed+10−1
src/Text/Pandoc/Readers/Org.hs+1−1 tests/Tests/Readers/Org.hs+9
src/Text/Pandoc/Readers/Org.hs+1−1
@@ -409,7 +409,7 @@ verseBlock blkProp = try $ do
409409 ignHeaders
410410 content <- rawBlockContent blkProp
411411 fmap B.para . mconcat . intersperse (pure B.linebreak)
412− <$> mapM (parseFromString parseInlines) (lines content)
412+ <$> mapM (parseFromString parseInlines) (map (++ "\n") . lines $ content)
413413
414414exportsCode :: [(String, String)] -> Bool
415415exportsCode attrs = not (("rundoc-exports", "none") `elem` attrs
tests/Tests/Readers/Org.hs+9
@@ -1143,6 +1143,15 @@ tests =
11431143 ]
11441144 ]
11451145
1146+ , "Verse block with newlines" =:
1147+ unlines [ "#+BEGIN_VERSE"
1148+ , "foo"
1149+ , ""
1150+ , "bar"
1151+ , "#+END_VERSE"
1152+ ] =?>
1153+ para ("foo" <> linebreak <> linebreak <> "bar")
1154+
11461155 , "LaTeX fragment" =:
11471156 unlines [ "\\begin{equation}"
11481157 , "X_i = \\begin{cases}"