Skip to content

Commit fe90eda

Browse files
Merge pull request #166 from nobodywasishere/markdown_code_block
Add support for Crystal syntax highlighting in Markdown code blocks
2 parents 2ed10ad + cde76b5 commit fe90eda

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
".slang"
6767
],
6868
"configuration": "./slang-configuration.json"
69+
},
70+
{
71+
"id": "crystal-markdown-injection"
6972
}
7073
],
7174
"grammars": [
@@ -83,6 +86,17 @@
8386
"language": "slang",
8487
"scopeName": "text.slang",
8588
"path": "./syntaxes/slang.json"
89+
},
90+
{
91+
"language": "crystal-markdown-injection",
92+
"scopeName": "markdown.crystal.codeblock",
93+
"path": "./syntaxes/codeblock.json",
94+
"injectTo": [
95+
"text.html.markdown"
96+
],
97+
"embeddedLanguages": {
98+
"meta.embedded.block.crystal": "crystal"
99+
}
86100
}
87101
],
88102
"snippets": [

syntaxes/codeblock.json

Lines changed: 45 additions & 0 deletions
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": "#superjs-code-block"
7+
}
8+
],
9+
"repository": {
10+
"superjs-code-block": {
11+
"begin": "(^|\\G)(\\s*)(\\`{3,}|~{3,})\\s*(?i:(crystal|cr)(\\s+[^`~]*)?$)",
12+
"name": "markup.fenced_code.block.markdown",
13+
"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
14+
"beginCaptures": {
15+
"3": {
16+
"name": "punctuation.definition.markdown"
17+
},
18+
"4": {
19+
"name": "fenced_code.block.language.markdown"
20+
},
21+
"5": {
22+
"name": "fenced_code.block.language.attributes.markdown"
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.crystal",
35+
"patterns": [
36+
{
37+
"include": "source.crystal"
38+
}
39+
]
40+
}
41+
]
42+
}
43+
},
44+
"scopeName": "markdown.crystal.codeblock"
45+
}

0 commit comments

Comments
 (0)