diff options
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 17 | ||||
-rw-r--r-- | test/command/4134.md | 25 |
2 files changed, 39 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index d1d9682c3..90d0fe5d1 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -332,9 +332,20 @@ totoks pos t = in Tok pos (CtrlSeq ws) ("\\" <> ws <> ss) : totoks (incSourceColumn pos (1 + T.length ws + T.length ss)) rest''' - | d == '\t' || d == '\n' -> - Tok pos Symbol "\\" - : totoks (incSourceColumn pos 1) rest + | isSpaceOrTab d || d == '\n' -> + let (w1, r1) = T.span isSpaceOrTab rest + (w2, (w3, r3)) = case T.uncons r1 of + Just ('\n', r2) + -> (T.pack "\n", + T.span isSpaceOrTab r2) + _ -> (mempty, (w1, r1)) + in case T.uncons r3 of + Just ('\n', _) -> + Tok pos (CtrlSeq " ") ("\\" <> w1) + : totoks (incSourceColumn pos 1) r1 + _ -> + Tok pos (CtrlSeq " ") ("\\" <> w1 <> w2 <> w3) + : totoks (incSourceColumn pos 1) r3 | otherwise -> Tok pos (CtrlSeq (T.singleton d)) (T.pack [c,d]) : totoks (incSourceColumn pos 2) rest' diff --git a/test/command/4134.md b/test/command/4134.md new file mode 100644 index 000000000..b5473d948 --- /dev/null +++ b/test/command/4134.md @@ -0,0 +1,25 @@ +``` +% pandoc -f latex -t native +Hello.\ +world. +^D +[Para [Str "Hello.\160world."]] +``` + +``` +% pandoc -f latex -t native +Hello.\ + world. +^D +[Para [Str "Hello.\160world."]] +``` + +``` +% pandoc -f latex -t native +Hello.\ + +World. +^D +[Para [Str "Hello.\160"] +,Para [Str "World."]] +``` |