(LaTeX) Matching TeX magic comments should be case insensitive
See original GitHub issueDescribe the issue
TeX magic comments are, in most editors, case insensitive, so both lines below are interpreted:
% !TeX program = lualatex
% !TEX encoding = UTF-8
% ^ note e vs. E here
but the MAGIC_COMMENT
rule only highlights the TeX
(first) line:
Which language seems to have the issue?
latex
Are you using highlight
or highlightAuto
?
I don’t know? highlight
I think because the language is specified explicitly.
Sample Code to Reproduce
% !TeX program = lualatex
% !TEX encoding = UTF-8
% ^ note e vs. E here
Expected behavior
In the sample above, lines 1 and 2 should be highlighted as MAGIC_COMMENT
, and line 3 should be a regular COMMENT
:
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
compiling - When and why should I use % !TEX TS-program ...
My comments apply in principle to both TeXShop and TeXworks. ... 〈program〉 should be one of the programs set up in TeXworks and...
Read more >Advanced Usage | LTeX - valentjn
Magic comments are case-insensitive (except for the setting values), and the spaces in the magic comment line can be any amount of whitespace, ......
Read more >TeXstudio : user manual
Before using TeXstudio, you should configure the editor and latex related ... save the language of the file TeXstudio supports a special "magic...
Read more >User manual - TeXstudio
Here we assume that TeXstudio and a LaTeX-system are already installed on ... a case-insensitive search, a global search (continue after the first...
Read more >The SageTEX package
you that using graphics well is not easy, and no LATEX package or ... matched up to Sage's baked-in SageTEX support, so you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.
!
. I have never seen this and according to your list only LaTeX-Workshop supports it. I guess the idea is to allow%! TeX
and I sympathise with your point about remembering where spaces are allowed, but this feels like too much of a niche case to me.tEx
is a bit absurd, but should we maybe allowtex
andbib
? This seems a reasonable spelling to me (for the editors that support them) and is also in line with the “just use lowercase” default many technical users may be used to.About the
^
: At least TeXStudio accepts magic comments anywhere in the document with no restriction of being the only thing on that line. (I didn’t test any other editors.) While I myself only ever use them on the first lines of a document (with no indentation), I wouldn’t make that a requirement for highlighting.With all this my suggested regex would be
% ?!(?:T[eE]X|tex|BIB|bib)
. Any comments? (No pun intended.)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 😃