-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
(LaTeX) Matching TeX magic comments should be case insensitive #3243
Comments
That could well be a bug with the editor or it's highlighting... I presume you also mean that LaTex itself draws no distinction, am I correct? Or are we speaking about multiple flavors of LaTex here with different behaviors? I don't think I see any real issue with this though (making comment detection case insensitive). Thoughts? CC @schtandard |
No, as far as LaTeX is concerned magic comments are just comments: completely ignored. The magic is a feature implemented in some LaTeX-aware IDEs so that you can easily change command-line options from within the source (for example, with standard settings, an editor would run |
I don't see a reason why we couldn't accept a PR to fix this. |
@joshgoebel I'd write the PR myself, but I'm afraid my javascript knowledge is roughly zero, sorry: I just know enough LaTeX to come here and complain :) This is really of minor importance, so I'm fine with whenever someone knowledgeable has some free time to dedicate to this |
I fully agree that this should be changed and I can take care of this. The space in front of the |
@schtandard I did some digging, and the results vary wildly :)
I couldn't find anything about VimTeX or Overleaf, but this post says they support magic comments. AUCTeX uses its own thing at the end of the file; not sure if worth supporting, mostly because they aren't as “magic looking”: % Local Variables:
% mode: doctex
% TeX-master: t
% End: Finally, web2c implementations also allow a comment on the first line of a file of the format %&latex
\documentclass{article}
\begin{document}
\end{document} TL;DR Thinking a bit more about it, I don't think it's a good thing to highlight all the possible combinations (like Oh, and maybe |
@PhelypeOleinik Thanks a lot for your research! I mostly agree with your conclusions, except for two minor points. I don't feel strongly about either of them, though.
About the With all this my suggested regex would be |
Sounds reasonable. Given the plethora of different implementations, some level of restriction is good, so I'm fine with no space after
Sounds good too.
Go for it! (the regex, not the pun :) |
Describe the issue
TeX magic comments are, in most editors, case insensitive, so both lines below are interpreted:
but the
MAGIC_COMMENT
rule only highlights theTeX
(first) line:highlight.js/src/languages/latex.js
Lines 106 to 111 in 2dd87a6
Which language seems to have the issue?
latex
Are you using
highlight
orhighlightAuto
?I don't know?
highlight
I think because the language is specified explicitly.Sample Code to Reproduce
Expected behavior
In the sample above, lines 1 and 2 should be highlighted as
MAGIC_COMMENT
, and line 3 should be a regularCOMMENT
:The text was updated successfully, but these errors were encountered: