Skip to content

Commit 69016e8

Browse files
committed
vue(highlight): emit the raw-embed close rule once, lang-independent (#43)
The force-close orphan-close-line rules (`-close`/`-close-ml`) key on the TAG only — a close line carries no `lang=` — so emitting them per dialect produced byte-identical regex where only the first-included fired and the other four were dead (RedCMD #43: "will never match" / "all raw embedded languages"). The `<script>` tag was the only force-close dialect embed, so ts/tsx/jsx/coffee each shipped a duplicate close + close-ml; eight dead rules in all. Emit the close rules once, on the lang-less call, with the default embed — removing the duplicates and the regex shadowing (duplicate-regex rule groups: 2 → 0). The common `</script>`-on-its-own-line body is unaffected (handled lang-aware by the per-dialect begin/while contentName); only the rare code-on-the- close-line orphan body, which is lang-blind by construction (the #85 force-unwind drops that line, so it cannot carry the open tag's lang — documented tradeoff), now resolves via the neutral default embed instead of whichever dialect happened to be listed first. vue.tmLanguage.json −220 lines; all vue gates green (raw-style-embed 18/18, embed-boundary 9/9), scope-gap:vue unchanged (97.95%), tm-diagnostics clean, suite 39/39. Other #43 items are stale against the current grammar (the `-inline`/`-close` pairs are complementary `>`-on-line vs deferred-`>` shapes, not redundant), already fixed (the back-referenced `lang` quote rejects `"less'`), or a deliberate Onigmo-portability choice (`[Ss][Tt]…` over the non-portable `(?i:style)`).
1 parent 9081819 commit 69016e8

2 files changed

Lines changed: 8 additions & 222 deletions

File tree

src/gen-tm.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4002,6 +4002,12 @@ function generateMarkupTm(grammar: CstGrammar, grammarName: string, scopeName: s
40024002
// a single-line `<tag>…</tag>` (that whole line is the `-inline` shape, claimed earlier) nor
40034003
// swallow a following block's open tag, yet a bare `<` in the body (`a < b`) is fine. Agnostic:
40044004
// keys only on the tag + `<`/`/`/`>` delimiters (DATA), never on the embed's syntax.
4005+
top.push({ include: `#${key}` });
4006+
// The close-line rules (3)/(3b) key on the TAG ONLY (a close line carries no `lang=`), so emitting
4007+
// them per dialect yields byte-identical regex where only the first-included fires and the rest are
4008+
// dead (monogram#43 "will never match" / "all raw embedded languages"). Emit them ONCE — on the
4009+
// lang-less call (`langVal === undefined`), with the default embed — and skip them for every dialect.
4010+
if (langVal === undefined) {
40054011
repository[`${key}-close`] = {
40064012
name: `meta.${tag}.${L}`,
40074013
match: `^(\\s*)((?:(?!${o}${tagRe}\\b).)+?)(${o}${slash})(${tagRe})\\s*(${c})`,
@@ -4020,9 +4026,9 @@ function generateMarkupTm(grammar: CstGrammar, grammarName: string, scopeName: s
40204026
beginCaptures: { '2': bodyCap, '3': { name: sOpen }, '4': { name: sName } },
40214027
end: `(${c})`, endCaptures: { '1': { name: sClose } },
40224028
};
4023-
top.push({ include: `#${key}` });
4024-
top.push({ include: `#${key}-close` }); // orphan close line (BODY</tag>) — after the open-tag rules
4029+
top.push({ include: `#${key}-close` }); // orphan close line (BODY</tag>) — once per tag, lang-independent
40254030
top.push({ include: `#${key}-close-ml` }); // orphan close line with a DEFERRED `>` (#97)
4031+
}
40264032
} else {
40274033
// (2′) WELL-BEHAVED embed (no greedy construct can swallow the close, e.g. CSS) — a single
40284034
// `begin/end` region with a LOOKAHEAD `end` that never CONSUMES the close tag. Because the

vue.tmLanguage.json

Lines changed: 0 additions & 220 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)