MathJax-src icon indicating copy to clipboard operation
MathJax-src copied to clipboard

Skip TeX comments correctly. mathjax/MathJax#2271.

Open dpvc opened this issue 6 years ago • 2 comments

Update FindTeX to properly skip comments, even if they include unbalanced braces.

Resolves issue mathjax/MathJax#2271

dpvc avatar Dec 26 '19 20:12 dpvc

This is potentially a breaking change, so I am not going to include it in this version. The problem is that

... $$ x + y % comment $$ ...

would be processed by the current version (and version 2), but would not be processed by this PR, since the second $$ is now part of a comment. Although the behavior of this PR is the correct one for LaTeX, it might break existing content that takes advantage of this error in processing.

dpvc avatar Jan 03 '20 16:01 dpvc

There should also be additional changes to actually remove all comments before processing the rest of the expression, as currently that is not being done. For example,

\def\xyz#1%#2{[#1][#2]}

is valid, and can be used via \xyz a%b to get [a][b] as output. This is not how actual LaTeX works, and so this should be fixed as well. But I know that this is used on the Puzzling StackExchange site in some MathJax-based puzzles, and it will break those.

So I'm wondering if it is better to leave it as is, or break those incorrect (but useful) usages?

dpvc avatar Jan 03 '20 16:01 dpvc