Markdown: Ensure that expanded latex macros end with space if original did.
Closes #4442.
This commit is contained in:
parent
50885eabde
commit
339392bf54
2 changed files with 19 additions and 1 deletions
|
@ -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
|
||||
|
|
9
test/command/4442.md
Normal file
9
test/command/4442.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
```
|
||||
% pandoc -f markdown -t latex
|
||||
\newcommand{\myFruit}{Mango\xspace}
|
||||
\myFruit is the king of fruits.
|
||||
^D
|
||||
\newcommand{\myFruit}{Mango\xspace}
|
||||
|
||||
Mango\xspace is the king of fruits.
|
||||
```
|
Loading…
Add table
Reference in a new issue