WrapRmd icon indicating copy to clipboard operation
WrapRmd copied to clipboard

problems with wrapping lines containing latex code

Open IndrajeetPatil opened this issue 4 years ago • 2 comments

Before

image

Works as expected

image

After

image

But the extra \ introduced by WrapRmd creates problems for rendering the equations:

image

IndrajeetPatil avatar Dec 20 '20 16:12 IndrajeetPatil

WrapRmd runs the markdown through common mark which escapes the \’s. I would appreciate any input from people who want to help develop a way of unescaping the backslashes or finding a way to keep common mark from escaping them in the first place.

tjmahr avatar Dec 20 '20 18:12 tjmahr

I think the approach of using a regex for LaTeX similar to what was done for cross-references in this PR would work.

 re_latex <-  "((?!=[$])\\$[^$]*\\$)"
stringr::str_extract("$\alpha + \beta$ is 3", re_latex)
#> [1] "$\alpha + \beta$"

Created on 2021-04-08 by the reprex package (v2.0.0)

Please insert customary joke about solving a problem with regex 😀

AjayKMehta avatar Apr 09 '21 03:04 AjayKMehta