Skip to content

Commit 3f95aca

Browse files
committed
fix: highlight docstrip guards with a negated expression (v0.2.2)
Downstream report: %<*!driver>, %</!spa>, %<+!driver> rendered as plain text while %<*driver> / %<*fd|zhmap> worked. The marker charclass ate a single [*/+!-], so a * or / followed by a ! (negated docstrip expression) failed the expression sub-match and the whole guard went unhighlighted. Split marker ([*/+-]?) from the boolean expression (may start with ! or (), matching all docstrip forms. Verified end-to-end through the real DocTeX + expl3 grammar chain; added the reported forms to the fixture.
1 parent 0afa277 commit 3f95aca

4 files changed

Lines changed: 20 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [0.2.2] - 2026-07-06
4+
5+
### Fixed
6+
7+
- docstrip guards with a negated expression — `%<*!driver>`, `%</!spa>`,
8+
`%<+!driver>` — were not highlighted. The marker (`*`/`/`/`+`/`-`) and the
9+
boolean expression (which may start with `!` or `(`) are now matched
10+
separately, so all docstrip forms highlight correctly.
11+
312
## [0.2.1] - 2026-07-06
413

514
### Added

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "expl3-vscode",
33
"displayName": "expl3 (LaTeX3) Language Support",
44
"description": "Syntax highlighting and explcheck diagnostics for expl3 (LaTeX3) code.",
5-
"version": "0.2.1",
5+
"version": "0.2.2",
66
"publisher": "CTeX-org",
77
"license": "MIT",
88
"icon": "images/icon.png",

syntaxes/expl3.tmLanguage.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
}
2323
},
2424
{
25-
"comment": "docstrip open/close/single guard: %<*tag>, %</tag>, %<+tag>, %<!tag>, %<tag>",
26-
"match": "(?x) ^ (%) (<) ([*/+!-]?) ([A-Za-z_][A-Za-z0-9_|&!,+-]*) (>)",
25+
"comment": "docstrip block/inline guard: %<*expr>, %</expr>, %<+expr>, %<expr>. The optional *,/,+,- marker selects the block direction; expr is a docstrip boolean expression that may itself start with ! (negation) or ( and use |, &, ! operators, e.g. %<*!driver>, %<*fd|zhmap>, %<*a&!b>.",
26+
"match": "(?x) ^ (%) (<) ([*/+-]?) ([A-Za-z_!(][A-Za-z0-9_|&!,+()-]*) (>)",
2727
"captures": {
2828
"1": { "name": "punctuation.definition.comment.tex" },
2929
"2": { "name": "punctuation.definition.tag.docstrip.expl3" },

tests/fixtures/xeCJK-sample.dtx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,11 @@
7676
%<*!driver&(package|config)>
7777
% conditional guarded region using boolean expressions
7878
%</!driver&(package|config)>
79+
80+
% docstrip marker + negated expression (from ctex-fontset.dtx; issue: these
81+
% must highlight just like the plain forms above)
82+
%<*!driver>
83+
%<+!driver>\GetIdInfo $Id: demo.dtx 1.0 2026-01-01 A B <a@b.c>$
84+
%</!driver>
85+
%<*!spa>
86+
%</!spa>

0 commit comments

Comments
 (0)