Skip to content

Commit 0e6d01d

Browse files
committed
Refactor: Add CSS injection grammar support and enhance highlighting for @master directives in language package
1 parent 496df76 commit 0e6d01d

6 files changed

Lines changed: 612 additions & 4 deletions

File tree

‎packages/compiler/AI.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Prefer using the public `@master/css` engine for rule generation.
1919
- Avoid duplicating core parser, selector, priority, and layer behavior.
2020
- Do not reintroduce PostCSS in this package.
21+
- If `@master` CSS configuration syntax is expanded or changed incompatibly, update the TextMate/Shiki highlighting in `packages/language` in the same change when practical.
2122

2223
## Directive MVP
2324

‎packages/language/AI.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This package owns the Master CSS language declaration and TextMate/Shiki grammar
2020

2121
- Grammar changes affect VS Code, Shiki, docs highlighting, and package generation.
2222
- `packages/vscode/generate.ts` reads this package to update VS Code grammar contributions.
23+
- `packages/compiler` owns the `@master` CSS configuration directives; breaking or expanding that syntax usually requires matching grammar updates here.
2324

2425
## Rules
2526

@@ -34,4 +35,3 @@ pnpm --filter @master/css-language build
3435
pnpm --filter @master/css-language type-check
3536
pnpm --filter master-css-vscode build
3637
```
37-

‎packages/language/src/grammars.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export declare type Grammar = {
1212

1313
const core = (await import('../syntaxes/master-css.json')).default
1414
const injectionClass = (await import('../syntaxes/master-css.injection-class.json')).default
15+
const injectionCSS = (await import('../syntaxes/master-css.injection-css.json')).default
1516
const injectionJS = (await import('../syntaxes/master-css.injection-js.json')).default
1617
const injectionReact = (await import('../syntaxes/master-css.injection-react.json')).default
1718
const injectionString = (await import('../syntaxes/master-css.injection-string.json')).default
@@ -29,6 +30,19 @@ const grammars = [
2930
'text'
3031
]
3132
},
33+
{
34+
...injectionCSS,
35+
injectTo: [
36+
'source.css',
37+
'source.css.scss'
38+
],
39+
embeddedLangs: [
40+
'master-css'
41+
],
42+
vscodeEmbeddedLanguages: {
43+
'meta.embedded.block.master-css.class': 'master-css'
44+
},
45+
},
3246
{
3347
...injectionReact,
3448
injectTo: [

0 commit comments

Comments
 (0)