aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-12-15 09:45:29 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2017-12-15 09:45:29 -0800
commit044d58bb24cf41493222a14612e2de4f8d05ea6a (patch)
tree7eccdd8ace65b6de7dd293cfb69604277d790da0
parent61133b52687ac96dd4171d189d9770cae2ae7a6c (diff)
downloadpandoc-044d58bb24cf41493222a14612e2de4f8d05ea6a.tar.gz
Fixed regression in LateX tokenization.
This mainly affects the Markdown reader when parsing raw LaTeX with escaped spaces. Closes #4159.
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs4
-rw-r--r--test/command/4159.md8
2 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 90d0fe5d1..fab97347b 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -320,7 +320,7 @@ totoks pos t =
: totoks (incSourceColumn pos (1 + T.length cs)) rest'
| c == '\\' ->
case T.uncons rest of
- Nothing -> [Tok pos Symbol (T.singleton c)]
+ Nothing -> [Tok pos (CtrlSeq " ") "\\"]
Just (d, rest')
| isLetterOrAt d ->
-- \makeatletter is common in macro defs;
@@ -338,7 +338,7 @@ totoks pos t =
Just ('\n', r2)
-> (T.pack "\n",
T.span isSpaceOrTab r2)
- _ -> (mempty, (w1, r1))
+ _ -> (mempty, (mempty, r1))
in case T.uncons r3 of
Just ('\n', _) ->
Tok pos (CtrlSeq " ") ("\\" <> w1)
diff --git a/test/command/4159.md b/test/command/4159.md
new file mode 100644
index 000000000..4881edcc5
--- /dev/null
+++ b/test/command/4159.md
@@ -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"]]
+```