@cssdoc/tmlanguage 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +46 -0
- package/cssdoc.injection.tmLanguage.json +61 -0
- package/dist/index.d.mts +81 -0
- package/dist/index.mjs +97 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Danny Wahl
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @cssdoc/tmlanguage
|
|
2
|
+
|
|
3
|
+
A TextMate **injection** grammar that highlights cssdoc doc-comment tags inside CSS comments — the way
|
|
4
|
+
TSDoc highlights JSDoc tags inside `/** … */`. It layers onto the host CSS grammar's comment scope
|
|
5
|
+
(`comment.block.css`, and the SCSS/Less equivalents), so cssdoc tags light up wherever CSS is
|
|
6
|
+
highlighted, including CSS embedded in HTML `<style>`.
|
|
7
|
+
|
|
8
|
+
It highlights the record and block tags (`@component`, `@modifier`, `@part`, `@cssproperty`, …), the
|
|
9
|
+
release modifiers (`@alpha`, `@beta`, `@public`, …), inline tags (`{@link}`, `{@inheritDoc}`,
|
|
10
|
+
`{@label}`), and custom properties (`--foo`).
|
|
11
|
+
|
|
12
|
+
## Use with Shiki or VitePress
|
|
13
|
+
|
|
14
|
+
The default export is a Shiki `LanguageRegistration` with `injectTo` already set, so registering it makes
|
|
15
|
+
every CSS block pick up the highlighting:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// .vitepress/config.ts
|
|
19
|
+
import cssdoc from "@cssdoc/tmlanguage";
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
markdown: {
|
|
23
|
+
languages: [cssdoc],
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Use in a VS Code extension
|
|
29
|
+
|
|
30
|
+
Reference the raw grammar from `contributes.grammars` and inject it into CSS:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"contributes": {
|
|
35
|
+
"grammars": [
|
|
36
|
+
{
|
|
37
|
+
"scopeName": "documentation.cssdoc",
|
|
38
|
+
"path": "./cssdoc.injection.tmLanguage.json",
|
|
39
|
+
"injectTo": ["source.css"]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The file is published at `@cssdoc/tmlanguage/cssdoc.injection.tmLanguage.json`.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
|
3
|
+
"name": "cssdoc",
|
|
4
|
+
"scopeName": "documentation.cssdoc",
|
|
5
|
+
"injectionSelector": "L:comment.block.css, L:comment.block.scss, L:comment.block.less",
|
|
6
|
+
"patterns": [
|
|
7
|
+
{ "include": "#inline-tag" },
|
|
8
|
+
{ "include": "#modifier-tag" },
|
|
9
|
+
{ "include": "#part-tag" },
|
|
10
|
+
{ "include": "#property-tag" },
|
|
11
|
+
{ "include": "#block-tag" },
|
|
12
|
+
{ "include": "#custom-property" }
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"inline-tag": {
|
|
16
|
+
"name": "meta.inline-tag.cssdoc",
|
|
17
|
+
"begin": "(\\{)(@(?:link|inheritDoc|label))\\b",
|
|
18
|
+
"beginCaptures": {
|
|
19
|
+
"1": { "name": "punctuation.definition.tag.begin.cssdoc" },
|
|
20
|
+
"2": { "name": "storage.type.class.cssdoc" }
|
|
21
|
+
},
|
|
22
|
+
"end": "(\\})",
|
|
23
|
+
"endCaptures": {
|
|
24
|
+
"1": { "name": "punctuation.definition.tag.end.cssdoc" }
|
|
25
|
+
},
|
|
26
|
+
"patterns": [
|
|
27
|
+
{ "match": "\\|", "name": "punctuation.separator.cssdoc" },
|
|
28
|
+
{ "match": "[^}|]+", "name": "markup.underline.link.cssdoc" }
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"modifier-tag": {
|
|
32
|
+
"match": "(@modifier)\\b[ \\t]*(-[A-Za-z][A-Za-z0-9-]*)?",
|
|
33
|
+
"captures": {
|
|
34
|
+
"1": { "name": "storage.type.class.cssdoc" },
|
|
35
|
+
"2": { "name": "variable.other.modifier.cssdoc" }
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"part-tag": {
|
|
39
|
+
"match": "(@(?:csspart|part|slot))\\b[ \\t]*(\\.?[A-Za-z][A-Za-z0-9_-]*)?",
|
|
40
|
+
"captures": {
|
|
41
|
+
"1": { "name": "storage.type.class.cssdoc" },
|
|
42
|
+
"2": { "name": "entity.other.attribute-name.part.cssdoc" }
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"property-tag": {
|
|
46
|
+
"match": "(@(?:cssproperty|property))\\b[ \\t]*(--[A-Za-z][A-Za-z0-9-]*)?",
|
|
47
|
+
"captures": {
|
|
48
|
+
"1": { "name": "storage.type.class.cssdoc" },
|
|
49
|
+
"2": { "name": "support.type.custom-property.cssdoc" }
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"block-tag": {
|
|
53
|
+
"match": "(@(?:component|name|utility|rule|declaration|class|summary|remarks|privateRemarks|deprecated|example|see|since|group|category|defaultValue|cssstate|function|keyframes|animation|layer|container|supports|media|responsive|a11y|accessibility|structure|demo|alpha|beta|experimental|internal|public))\\b",
|
|
54
|
+
"name": "storage.type.class.cssdoc"
|
|
55
|
+
},
|
|
56
|
+
"custom-property": {
|
|
57
|
+
"match": "(?<![\\w-])--[A-Za-z][A-Za-z0-9-]*",
|
|
58
|
+
"name": "support.type.custom-property.cssdoc"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//#region src/index.d.ts
|
|
2
|
+
/** The scopes the injection layers onto (CSS, plus SCSS/Less and CSS embedded in HTML `<style>`). */
|
|
3
|
+
declare const injectTo: string[];
|
|
4
|
+
/** The cssdoc doc-comment injection grammar, shaped as a Shiki `LanguageRegistration`. */
|
|
5
|
+
declare const cssdoc: {
|
|
6
|
+
injectTo: string[];
|
|
7
|
+
$schema: string;
|
|
8
|
+
name: string;
|
|
9
|
+
scopeName: string;
|
|
10
|
+
injectionSelector: string;
|
|
11
|
+
patterns: {
|
|
12
|
+
include: string;
|
|
13
|
+
}[];
|
|
14
|
+
repository: {
|
|
15
|
+
"inline-tag": {
|
|
16
|
+
name: string;
|
|
17
|
+
begin: string;
|
|
18
|
+
beginCaptures: {
|
|
19
|
+
"1": {
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
"2": {
|
|
23
|
+
name: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
end: string;
|
|
27
|
+
endCaptures: {
|
|
28
|
+
"1": {
|
|
29
|
+
name: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
patterns: {
|
|
33
|
+
match: string;
|
|
34
|
+
name: string;
|
|
35
|
+
}[];
|
|
36
|
+
};
|
|
37
|
+
"modifier-tag": {
|
|
38
|
+
match: string;
|
|
39
|
+
captures: {
|
|
40
|
+
"1": {
|
|
41
|
+
name: string;
|
|
42
|
+
};
|
|
43
|
+
"2": {
|
|
44
|
+
name: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
"part-tag": {
|
|
49
|
+
match: string;
|
|
50
|
+
captures: {
|
|
51
|
+
"1": {
|
|
52
|
+
name: string;
|
|
53
|
+
};
|
|
54
|
+
"2": {
|
|
55
|
+
name: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
"property-tag": {
|
|
60
|
+
match: string;
|
|
61
|
+
captures: {
|
|
62
|
+
"1": {
|
|
63
|
+
name: string;
|
|
64
|
+
};
|
|
65
|
+
"2": {
|
|
66
|
+
name: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
"block-tag": {
|
|
71
|
+
match: string;
|
|
72
|
+
name: string;
|
|
73
|
+
};
|
|
74
|
+
"custom-property": {
|
|
75
|
+
match: string;
|
|
76
|
+
name: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
export { cssdoc, cssdoc as default, injectTo };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
//#region cssdoc.injection.tmLanguage.json
|
|
2
|
+
var cssdoc_injection_tmLanguage_default = {
|
|
3
|
+
$schema: "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
|
4
|
+
name: "cssdoc",
|
|
5
|
+
scopeName: "documentation.cssdoc",
|
|
6
|
+
injectionSelector: "L:comment.block.css, L:comment.block.scss, L:comment.block.less",
|
|
7
|
+
patterns: [
|
|
8
|
+
{ "include": "#inline-tag" },
|
|
9
|
+
{ "include": "#modifier-tag" },
|
|
10
|
+
{ "include": "#part-tag" },
|
|
11
|
+
{ "include": "#property-tag" },
|
|
12
|
+
{ "include": "#block-tag" },
|
|
13
|
+
{ "include": "#custom-property" }
|
|
14
|
+
],
|
|
15
|
+
repository: {
|
|
16
|
+
"inline-tag": {
|
|
17
|
+
"name": "meta.inline-tag.cssdoc",
|
|
18
|
+
"begin": "(\\{)(@(?:link|inheritDoc|label))\\b",
|
|
19
|
+
"beginCaptures": {
|
|
20
|
+
"1": { "name": "punctuation.definition.tag.begin.cssdoc" },
|
|
21
|
+
"2": { "name": "storage.type.class.cssdoc" }
|
|
22
|
+
},
|
|
23
|
+
"end": "(\\})",
|
|
24
|
+
"endCaptures": { "1": { "name": "punctuation.definition.tag.end.cssdoc" } },
|
|
25
|
+
"patterns": [{
|
|
26
|
+
"match": "\\|",
|
|
27
|
+
"name": "punctuation.separator.cssdoc"
|
|
28
|
+
}, {
|
|
29
|
+
"match": "[^}|]+",
|
|
30
|
+
"name": "markup.underline.link.cssdoc"
|
|
31
|
+
}]
|
|
32
|
+
},
|
|
33
|
+
"modifier-tag": {
|
|
34
|
+
"match": "(@modifier)\\b[ \\t]*(-[A-Za-z][A-Za-z0-9-]*)?",
|
|
35
|
+
"captures": {
|
|
36
|
+
"1": { "name": "storage.type.class.cssdoc" },
|
|
37
|
+
"2": { "name": "variable.other.modifier.cssdoc" }
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"part-tag": {
|
|
41
|
+
"match": "(@(?:csspart|part|slot))\\b[ \\t]*(\\.?[A-Za-z][A-Za-z0-9_-]*)?",
|
|
42
|
+
"captures": {
|
|
43
|
+
"1": { "name": "storage.type.class.cssdoc" },
|
|
44
|
+
"2": { "name": "entity.other.attribute-name.part.cssdoc" }
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"property-tag": {
|
|
48
|
+
"match": "(@(?:cssproperty|property))\\b[ \\t]*(--[A-Za-z][A-Za-z0-9-]*)?",
|
|
49
|
+
"captures": {
|
|
50
|
+
"1": { "name": "storage.type.class.cssdoc" },
|
|
51
|
+
"2": { "name": "support.type.custom-property.cssdoc" }
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"block-tag": {
|
|
55
|
+
"match": "(@(?:component|name|utility|rule|declaration|class|summary|remarks|privateRemarks|deprecated|example|see|since|group|category|defaultValue|cssstate|function|keyframes|animation|layer|container|supports|media|responsive|a11y|accessibility|structure|demo|alpha|beta|experimental|internal|public))\\b",
|
|
56
|
+
"name": "storage.type.class.cssdoc"
|
|
57
|
+
},
|
|
58
|
+
"custom-property": {
|
|
59
|
+
"match": "(?<![\\w-])--[A-Za-z][A-Za-z0-9-]*",
|
|
60
|
+
"name": "support.type.custom-property.cssdoc"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/index.ts
|
|
66
|
+
/**
|
|
67
|
+
* `@cssdoc/tmlanguage` — a TextMate injection grammar that highlights cssdoc doc-comment tags inside
|
|
68
|
+
* CSS comments, the way TSDoc highlights JSDoc tags inside `/** … *\/` comments. It layers onto the host
|
|
69
|
+
* CSS grammar's comment scope, so `@component`, `@modifier`, `@cssproperty`, `{@link …}`, the release
|
|
70
|
+
* modifiers, and custom properties light up wherever CSS is highlighted.
|
|
71
|
+
*
|
|
72
|
+
* The default export is the grammar as a Shiki `LanguageRegistration` (it carries `injectTo`), so it
|
|
73
|
+
* drops into a Shiki or VitePress config; the raw grammar is also published at
|
|
74
|
+
* `./cssdoc.injection.tmLanguage.json` for VS Code's `contributes.grammars` and other TextMate hosts.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* // .vitepress/config.ts
|
|
79
|
+
* import cssdoc from "@cssdoc/tmlanguage";
|
|
80
|
+
* export default { markdown: { languages: [cssdoc] } };
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @module @cssdoc/tmlanguage
|
|
84
|
+
*/
|
|
85
|
+
/** The scopes the injection layers onto (CSS, plus SCSS/Less and CSS embedded in HTML `<style>`). */
|
|
86
|
+
const injectTo = [
|
|
87
|
+
"source.css",
|
|
88
|
+
"source.scss",
|
|
89
|
+
"source.less"
|
|
90
|
+
];
|
|
91
|
+
/** The cssdoc doc-comment injection grammar, shaped as a Shiki `LanguageRegistration`. */
|
|
92
|
+
const cssdoc = {
|
|
93
|
+
...cssdoc_injection_tmLanguage_default,
|
|
94
|
+
injectTo
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
export { cssdoc, cssdoc as default, injectTo };
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cssdoc/tmlanguage",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A TextMate injection grammar that highlights cssdoc doc-comment tags inside CSS comments, the way TSDoc highlights JSDoc tags. Ships as a Shiki language.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"css",
|
|
7
|
+
"cssdoc",
|
|
8
|
+
"injection",
|
|
9
|
+
"shiki",
|
|
10
|
+
"syntax-highlighting",
|
|
11
|
+
"textmate",
|
|
12
|
+
"tmlanguage"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://cssdoc.dev",
|
|
15
|
+
"bugs": "https://github.com/thedannywahl/cssdoc/issues",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/thedannywahl/cssdoc.git",
|
|
20
|
+
"directory": "syntaxes/cssdoc"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"cssdoc.injection.tmLanguage.json"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": "./dist/index.mjs",
|
|
29
|
+
"./cssdoc.injection.tmLanguage.json": "./cssdoc.injection.tmLanguage.json",
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^24.13.3",
|
|
37
|
+
"@vitest/coverage-v8": "4.1.9",
|
|
38
|
+
"publint": "^0.3.21",
|
|
39
|
+
"typescript": "^6.0.3",
|
|
40
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.2.4",
|
|
41
|
+
"vite-plus": "0.2.4"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "vp pack",
|
|
45
|
+
"dev": "vp pack --watch",
|
|
46
|
+
"test": "vp test",
|
|
47
|
+
"check": "vp check",
|
|
48
|
+
"publint": "publint"
|
|
49
|
+
}
|
|
50
|
+
}
|