|
9 | 9 | // tags). It does not implement the WHATWG error-recovery tree-construction |
10 | 10 | // algorithm (that is not a context-free grammar); conformance is measured against |
11 | 11 | // `parse5` on well-formed input. See memory: html-vue-markup. |
12 | | -import { token, rule, defineGrammar, many, opt, alt, seq, oneOf, noneOf, range, anyChar, star, plus, notFollowedBy } from './src/api.ts'; |
| 12 | +import { token, rule, defineGrammar, many, opt, alt, lit, seq, oneOf, noneOf, range, anyChar, star, plus, notFollowedBy } from './src/api.ts'; |
13 | 13 | import type { MarkupConfig } from './src/types.ts'; |
14 | 14 |
|
15 | 15 | // ── Tokens ── |
| 16 | +// ASCII word chars [A-Za-z0-9_] — NOT `\w` (Oniguruma treats `\w` as Unicode-aware); tag/attr |
| 17 | +// names and the `on*` embed selector are intentionally ASCII, so the IR enumerates the set. |
16 | 18 | const word = oneOf(range('A', 'Z'), range('a', 'z'), range('0', '9'), '_'); |
17 | 19 | const whitespace = oneOf('\t', '\n', '\f', '\r', ' '); |
18 | 20 |
|
@@ -120,8 +122,8 @@ export const markup: MarkupConfig = { |
120 | 122 | // VS Code's own HTML grammar (a flat source.css blob there) and matching the hand-written Vue |
121 | 123 | // grammar's `#vue-directives-style-attr` (its "Copy from source.css#rule-list-innards"). |
122 | 124 | attributeEmbed: [ |
123 | | - { namePattern: 'on\\w+', embed: 'source.js' }, |
124 | | - { namePattern: 'style', embed: 'source.css', include: 'source.css#rule-list-innards' }, |
| 125 | + { namePattern: seq(lit('on'), plus(word)), embed: 'source.js' }, |
| 126 | + { namePattern: lit('style'), embed: 'source.css', include: 'source.css#rule-list-innards' }, |
125 | 127 | ], |
126 | 128 | // Raw-text element bodies are scanned verbatim by the parser, but the HIGHLIGHTER |
127 | 129 | // delegates `<script>`/`<style>` to the platform's real JS/CSS grammars (exactly as |
|
0 commit comments