aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/LaTeX
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Readers/LaTeX')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX/Parsing.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
index a265d6ca2..eeebab3e6 100644
--- a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
@@ -226,7 +226,16 @@ rawLaTeXParser retokenize parser valParser = do
Right ((val, raw), st) -> do
updateState (updateMacros (sMacros st <>))
_ <- takeP (T.length (untokenize toks'))
- return (val, T.unpack (untokenize raw))
+ let result = untokenize raw
+ -- ensure we end with space if input did, see #4442
+ let result' =
+ case reverse toks' of
+ (Tok _ (CtrlSeq _) t : _)
+ | " " `T.isSuffixOf` t
+ , not (" " `T.isSuffixOf` result)
+ -> result <> " "
+ _ -> result
+ return (val, T.unpack result')
applyMacros :: (PandocMonad m, HasMacros s, HasReaderOptions s)
=> String -> ParserT String s m String