aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-09-29 10:57:11 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-09-29 10:57:11 -0700
commit190ee279c9c10c6e87248428dcdbd73ab9036373 (patch)
treee201c4b40c3cd2baaa8f7d579a8b12e6cea60341 /src/Text/Pandoc/Readers
parentc6d56f026f27519e913f64d843450c7a32f957fb (diff)
downloadpandoc-190ee279c9c10c6e87248428dcdbd73ab9036373.tar.gz
LaTeX reader: allow verbatim blocks ending with blank lines.
Closes #4624.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 8a8b7dfb6..17d1c4bc9 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -2145,7 +2145,20 @@ verbEnv name = withVerbatimMode $ do
skipopts
optional blankline
res <- manyTill anyTok (end_ name)
- return $ stripTrailingNewlines $ toksToString res
+ return $ T.unpack
+ $ stripTrailingNewline
+ $ untokenize
+ $ res
+
+-- Strip single final newline and any spaces following it.
+-- Input is unchanged if it doesn't end with newline +
+-- optional spaces.
+stripTrailingNewline :: Text -> Text
+stripTrailingNewline t =
+ let (b, e) = T.breakOnEnd "\n" t
+ in if T.all (== ' ') e
+ then T.dropEnd 1 b
+ else t
fancyverbEnv :: PandocMonad m => Text -> LP m Blocks
fancyverbEnv name = do