Fixed regression in LateX tokenization.

This mainly affects the Markdown reader when parsing
raw LaTeX with escaped spaces.  Closes #4159.
This commit is contained in:
John MacFarlane 2017-12-15 09:45:29 -08:00
parent 61133b5268
commit 044d58bb24
2 changed files with 10 additions and 2 deletions

View file

@ -320,7 +320,7 @@ totoks pos t =
: totoks (incSourceColumn pos (1 + T.length cs)) rest' : totoks (incSourceColumn pos (1 + T.length cs)) rest'
| c == '\\' -> | c == '\\' ->
case T.uncons rest of case T.uncons rest of
Nothing -> [Tok pos Symbol (T.singleton c)] Nothing -> [Tok pos (CtrlSeq " ") "\\"]
Just (d, rest') Just (d, rest')
| isLetterOrAt d -> | isLetterOrAt d ->
-- \makeatletter is common in macro defs; -- \makeatletter is common in macro defs;
@ -338,7 +338,7 @@ totoks pos t =
Just ('\n', r2) Just ('\n', r2)
-> (T.pack "\n", -> (T.pack "\n",
T.span isSpaceOrTab r2) T.span isSpaceOrTab r2)
_ -> (mempty, (w1, r1)) _ -> (mempty, (mempty, r1))
in case T.uncons r3 of in case T.uncons r3 of
Just ('\n', _) -> Just ('\n', _) ->
Tok pos (CtrlSeq " ") ("\\" <> w1) Tok pos (CtrlSeq " ") ("\\" <> w1)

8
test/command/4159.md Normal file
View file

@ -0,0 +1,8 @@
```
% pandoc -f markdown -t native
\newcommand{\gen}{a\ Gen\ b}
abc
^D
[RawBlock (Format "latex") "\\newcommand{\\gen}{a\\ Gen\\ b}"
,Para [Str "abc"]]
```