Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MarkdownLiteral handles backslashes in unexpected ways. #8

Open
snoeyink opened this issue Sep 8, 2022 · 0 comments
Open

MarkdownLiteral handles backslashes in unexpected ways. #8

snoeyink opened this issue Sep 8, 2022 · 0 comments

Comments

@snoeyink
Copy link

snoeyink commented Sep 8, 2022

Context: The CommonMark parser does not do interpolation into code, latex, or HTML environments. MarkdownLiteral.jl, by using @htl first, supports interpolation into those environments. But by working on Julia strings, and not giving the option to work on raw strings, it handles backslashes in unexpected ways.

  1. In Latex, backslashes must be doubled. cm"``\LaTeX``" must become @mdx "``\\LaTeX``"
  2. In text, backslashes must be redoubled. cm"\@at" must become @mdx "\\\\\\@at".

Elaborating: Since Julia string processing uses backslash to escape characters, it does not play well with \LaTeX -- any backslashes have to be doubled. CommonMark avoids this by providing cm" " to operate on raw strings, so cm"Text ``\LaTeX``" can process MathJax inside the double back-ticks before the Julia string processing to the rest of the string. I suggested (Issue #6) a way for MarkdownLiteral to also accept raw strings, but this was not accepted. Thus, I need another way for MarkdownLiteral to accept LaTeX.

Since MarkdownLiteral uses @htl then @cm, its can require two levels of backslash protection in text: to get the effect of cm"\@at", one has to write @mdx "\\\\\\@at". (Again, this would be fixed with allowing MarkdownLiteral to accept raw strings.)

This brief Pluto notebook illustrates these issues, and shows that using result = htl" " in place of result = @htl` could fix 1&2.
mdxTesting.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant