git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: fix \ before newline.

This should be a nonbreaking space, as long as it's not followed by a blank line. This has been fixed at the tokenizer level. Closes #4134.

commit67b6abc8065a290517ff1486d09b4e57fce19733 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 8 Dec 2017, 16:33 (9 years ago) parent677ff2a
2 files changed+39−3
src/Text/Pandoc/Readers/LaTeX.hs+14−3 test/command/4134.md+25
src/Text/Pandoc/Readers/LaTeX.hs+14−3
@@ -332,9 +332,20 @@ totoks pos t =
332332 in Tok pos (CtrlSeq ws) ("\\" <> ws <> ss)
333333 : totoks (incSourceColumn pos
334334 (1 + T.length ws + T.length ss)) rest'''
335− | d == '\t' || d == '\n' ->
336− Tok pos Symbol "\\"
337− : totoks (incSourceColumn pos 1) rest
335+ | isSpaceOrTab d || d == '\n' ->
336+ let (w1, r1) = T.span isSpaceOrTab rest
337+ (w2, (w3, r3)) = case T.uncons r1 of
338+ Just ('\n', r2)
339+ -> (T.pack "\n",
340+ T.span isSpaceOrTab r2)
341+ _ -> (mempty, (w1, r1))
342+ in case T.uncons r3 of
343+ Just ('\n', _) ->
344+ Tok pos (CtrlSeq " ") ("\\" <> w1)
345+ : totoks (incSourceColumn pos 1) r1
346+ _ ->
347+ Tok pos (CtrlSeq " ") ("\\" <> w1 <> w2 <> w3)
348+ : totoks (incSourceColumn pos 1) r3
338349 | otherwise ->
339350 Tok pos (CtrlSeq (T.singleton d)) (T.pack [c,d])
340351 : totoks (incSourceColumn pos 2) rest'
test/command/4134.mdnew file+25
@@ -0,0 +1,25 @@
1+```
2+% pandoc -f latex -t native
3+Hello.\
4+world.
5+^D
6+[Para [Str "Hello.\160world."]]
7+```
8+
9+```
10+% pandoc -f latex -t native
11+Hello.\
12+ world.
13+^D
14+[Para [Str "Hello.\160world."]]
15+```
16+
17+```
18+% pandoc -f latex -t native
19+Hello.\
20+
21+World.
22+^D
23+[Para [Str "Hello.\160"]
24+,Para [Str "World."]]
25+```