From 2229e7fe8ebb8f95eb2dbca7c1df423ff22a4a65 Mon Sep 17 00:00:00 2001 From: schtandard Date: Fri, 18 Jun 2021 18:55:14 +0200 Subject: [PATCH 1/4] Recognize wider syntax for magic comments --- src/languages/latex.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/latex.js b/src/languages/latex.js index 408e1d86b5..5efc55b869 100644 --- a/src/languages/latex.js +++ b/src/languages/latex.js @@ -105,7 +105,7 @@ export default function(hljs) { }; const MAGIC_COMMENT = { className: 'meta', - begin: '% !TeX', + begin: /% ?!(?:T[eE]X|tex|BIB|bib)/, end: '$', relevance: 10 }; From 21809c4e97d87f97fd893dad847c9638379c57c7 Mon Sep 17 00:00:00 2001 From: schtandard Date: Fri, 18 Jun 2021 18:58:24 +0200 Subject: [PATCH 2/4] Update CHANGES.md --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 358345934d..2858a2b664 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,7 @@ Grammars: - enh(elixir) updated list of keywords (#3212) [Angelika Tyborska][] - fix(elixir) fixed number detection when numbers start with a zero (#3212) [Angelika Tyborska][] - fix(ps1) Flag highlighted incorrectly (#3167) [Pankaj Patil][] +- fix(latex) Allow wider syntax for magic comments (#3243) [Benedikt Wilde][] [Stel Abrego]: https://github.com/stelcodes [Josh Goebel]: https://github.com/joshgoebel @@ -21,6 +22,7 @@ Grammars: [Konrad Rudolph]: https://github.com/klmr [tebeco]: https://github.com/tebeco [Pankaj Patil]: https://github.com/patil2099 +[Benedikt Wilde]: https://github.com/schtandard ## Version 11.0.0 From b6b641f0180663c8eb4d830b1a414ee249b3d6a7 Mon Sep 17 00:00:00 2001 From: schtandard Date: Fri, 18 Jun 2021 19:07:20 +0200 Subject: [PATCH 3/4] Add tests for new variants --- test/markup/latex/comments.expect.txt | 7 +++++++ test/markup/latex/comments.txt | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/test/markup/latex/comments.expect.txt b/test/markup/latex/comments.expect.txt index 69290f0496..abff4e9f73 100644 --- a/test/markup/latex/comments.expect.txt +++ b/test/markup/latex/comments.expect.txt @@ -2,3 +2,10 @@ foo% % !TeX program = pdflatex %% !TeX encoding = utf8 +%!TEX spellcheck = en-US +% !TeX foo +% !tex foo +% !tEx foo +% !BIB foo +%!bib foo +% !Bib foo diff --git a/test/markup/latex/comments.txt b/test/markup/latex/comments.txt index c12ec09044..2aa4c51ed1 100644 --- a/test/markup/latex/comments.txt +++ b/test/markup/latex/comments.txt @@ -2,3 +2,10 @@ foo% % !TeX program = pdflatex %% !TeX encoding = utf8 +%!TEX spellcheck = en-US +% !TeX foo +% !tex foo +% !tEx foo +% !BIB foo +%!bib foo +% !Bib foo From 0f91db3fef1b2e0c807310061288ba4d0a6220ce Mon Sep 17 00:00:00 2001 From: Benedikt Wilde Date: Fri, 18 Jun 2021 19:48:59 +0200 Subject: [PATCH 4/4] Do not use non-capturing group. Co-authored-by: Josh Goebel --- src/languages/latex.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/latex.js b/src/languages/latex.js index 5efc55b869..61f34d3907 100644 --- a/src/languages/latex.js +++ b/src/languages/latex.js @@ -105,7 +105,7 @@ export default function(hljs) { }; const MAGIC_COMMENT = { className: 'meta', - begin: /% ?!(?:T[eE]X|tex|BIB|bib)/, + begin: /% ?!(T[eE]X|tex|BIB|bib)/, end: '$', relevance: 10 };