dangmai / escape-latex

Escape LaTeX special characters with Javascript
MIT License
19 stars 4 forks source link

Newlines are incorrectly escaped #23

Closed aaliddell closed 6 years ago

aaliddell commented 6 years ago

One lines 22-23 the escaped newlines outputs have too many backslashes. This results in the word 'newline' appearing in the text when using preserveFormatting:

lescape("\n", {preserveFormatting: true})
-> '\\\\newline{}' as JS string
-> \\newline{} in LaTeX
-> word newline in document

Those lines should be:

"\r\n": "\\newline{}",
"\n": "\\newline{}",
dangmai commented 6 years ago

Thanks for the bug report :trophy: You're right, I'm not sure why I had it that way originally, but I just tried it in a couple of LaTeX documents and one backwards slash is enough. I'll make the change and release a new version of the library.

dangmai commented 6 years ago

I've released version 1.1.1 that should fix this issue.