Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Dec 25, 2025. It is now read-only.

Commit dfc2145

Browse files
committed
feat: add markdown support
1 parent cf8f771 commit dfc2145

File tree

3 files changed

+99
-1
lines changed

3 files changed

+99
-1
lines changed

package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,27 @@
4949
}
5050
],
5151
"grammars": [
52+
{
53+
"injectTo": [
54+
"source.html",
55+
"source.js",
56+
"source.js.jsx",
57+
"source.jsx",
58+
"source.ts",
59+
"source.tsx",
60+
"source.vue",
61+
"source.svelte",
62+
"source.sql",
63+
"source.css",
64+
"source.rescript",
65+
"text.html"
66+
],
67+
"scopeName": "inline.es6-markdown",
68+
"path": "./syntaxes/es6-inline-markdown.json",
69+
"embeddedLanguages": {
70+
"meta.embedded.markdown": "markdown"
71+
}
72+
},
5273
{
5374
"injectTo": [
5475
"source.html",

syntaxes/es6-inline-markdown.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"fileTypes": [
3+
"js",
4+
"jsx",
5+
"ts",
6+
"tsx",
7+
"html",
8+
"vue",
9+
"svelte",
10+
"php",
11+
"res"
12+
],
13+
"injectionSelector": "L:source.js -comment -string, L:source.js -comment -string, L:source.jsx -comment -string, L:source.js.jsx -comment -string, L:source.ts -comment -string, L:source.tsx -comment -string, L:source.rescript -comment -string",
14+
"injections": {
15+
"L:source": {
16+
"patterns": [
17+
{
18+
"match": "<",
19+
"name": "invalid.illegal.bad-angle-bracket.html"
20+
}
21+
]
22+
}
23+
},
24+
"patterns": [
25+
{
26+
"begin": "(?i)(\\s?\\/\\*\\s?(md|markdown)\\s?\\*\\/\\s?)(`)",
27+
"beginCaptures": {
28+
"1": {
29+
"name": "comment.block"
30+
},
31+
"3": {
32+
"name": "string.template.js"
33+
}
34+
},
35+
"end": "(`)",
36+
"endCaptures": {
37+
"1": {
38+
"name": "string.template.js"
39+
}
40+
},
41+
"patterns": [
42+
{ "include": "text.html.markdown" }
43+
]
44+
},
45+
{
46+
"begin": "(?i)(\\s*(md|markdown)`)",
47+
"beginCaptures": {
48+
"1": {
49+
"name": "string.template.js"
50+
}
51+
},
52+
"end": "(`)",
53+
"endCaptures": {
54+
"1": {
55+
"name": "string.template.js"
56+
}
57+
},
58+
"patterns": [
59+
{ "include": "text.html.markdown" }
60+
]
61+
}
62+
],
63+
"scopeName": "inline.es6-markdown"
64+
}

tests/test.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
<div attr="${test}asd${test}">Test</div>${elm}
3838
`;
3939

40+
variable = /* markdown */`this **is** ${test} _markdown_ `;
41+
variable = /* md */`this **is** _markdown_`;
42+
4043
variable = /*css*/`
4144
.className {
4245
color: red;
@@ -63,6 +66,16 @@
6366
const fn = (param) => param;
6467

6568
const html = (param) => html`<div>Something</div>`;
69+
const markdown = (param) => html`<div>Something</div>`;
70+
71+
fn(markdown`
72+
--- Hello
73+
hello **what is this**
74+
75+
1. foo
76+
1. bar
77+
1. baz
78+
`);
6679

6780
fn(//html
6881
`<div>Something</div>${elm}`
@@ -161,4 +174,4 @@ <h1>Test Header 2</h1>
161174

162175
</script>
163176
</body>
164-
</html>
177+
</html>

0 commit comments

Comments
 (0)