Skip to content

Commit d180824

Browse files
authored
Add markdown code block syntax highlight support (#97)
* syntax highlight in markdown code block * changelog
1 parent e9756ee commit d180824

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
- Inlay Hints (experimetal). `rescript.settings.inlayHints.enable: true`. Turned off by default.
1818
- Code Lenses for functions (experimetal). `rescript.settings.codeLens: true`. Turned off by default.
19+
- Markdown code blocks tagged as `rescript` now get basic syntax highlighting.
1920

2021
## v1.4.2
2122

grammars/rescript.markdown.json

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"fileTypes": [],
3+
"injectionSelector": "L:text.html.markdown",
4+
"patterns": [
5+
{
6+
"include": "#rescript-code-block"
7+
}
8+
],
9+
"repository": {
10+
"rescript-code-block": {
11+
"name": "markup.fenced_code.block.markdown",
12+
"begin": "(^|\\G)(\\s*)(\\`{3,}|~{3,})\\s*(?i:(res|rescript)(\\s+[^`~]*)?$)",
13+
"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
14+
"beginCaptures": {
15+
"3": {
16+
"name": "punctuation.definition.markdown"
17+
},
18+
"5": {
19+
"name": "fenced_code.block.language"
20+
},
21+
"6": {
22+
"name": "fenced_code.block.language.attributes"
23+
}
24+
},
25+
"endCaptures": {
26+
"3": {
27+
"name": "punctuation.definition.markdown"
28+
}
29+
},
30+
"patterns": [
31+
{
32+
"begin": "(^|\\G)(\\s*)(.*)",
33+
"while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)",
34+
"contentName": "meta.embedded.block.rescript",
35+
"patterns": [
36+
{
37+
"include": "source.rescript"
38+
}
39+
]
40+
}
41+
]
42+
}
43+
},
44+
"scopeName": "markdown.rescript.codeblock"
45+
}

package.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@
163163
"language": "rescript",
164164
"scopeName": "source.rescript",
165165
"path": "./grammars/rescript.tmLanguage.json"
166+
},
167+
{
168+
"scopeName": "markdown.rescript.codeblock",
169+
"path": "./grammars/rescript.markdown.json",
170+
"injectTo": [
171+
"text.html.markdown"
172+
],
173+
"embeddedLanguages": {
174+
"meta.embedded.block.rescript": "rescript"
175+
}
166176
}
167177
],
168178
"languages": [
@@ -191,4 +201,4 @@
191201
"@types/vscode": "1.68.0",
192202
"typescript": "^4.7.3"
193203
}
194-
}
204+
}

0 commit comments

Comments
 (0)