Skip to content

Commit

Permalink
Add highlighting to Markdown fenced code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjschuster authored and lpil committed May 10, 2024
1 parent b91f79b commit 6325dd7
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@
"language": "gleam",
"scopeName": "source.gleam",
"path": "./syntaxes/gleam.tmLanguage.json"
},
{
"scopeName": "markdown.gleam.codeblock",
"path": "./syntaxes/gleam.codeblock.json",
"injectTo": [
"text.html.markdown"
],
"embeddedLanguages": {
"meta.embedded.block.gleam": "gleam"
}
}
],
"snippets": [
Expand Down
48 changes: 48 additions & 0 deletions syntaxes/gleam.codeblock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"fileTypes": [],
"injectionSelector": "L:text.html.markdown",
"patterns": [
{
"include": "#gleam-code-block"
}
],
"repository": {
"gleam-code-block": {
"begin": "(^|\\G)(\\s*)(\\`{3,}|~{3,})\\s*(?i:(gleam)((\\s+|:|,|\\{|\\?)[^`]*)?$)",
"name": "markup.fenced_code.block.markdown",
"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
"beginCaptures": {
"3": {
"name": "punctuation.definition.markdown"
},
"4": {
"name": "fenced_code.block.language"
},
"7": {
"name": "punctuation.definition.markdown"
},
"8": {
"name": "fenced_code.block.language.attributes"
}
},
"endCaptures": {
"3": {
"name": "punctuation.definition.markdown"
}
},
"patterns": [
{
"begin": "(^|\\G)(\\s*)(.*)",
"while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)",
"contentName": "meta.embedded.block.gleam",
"patterns": [
{
"include": "source.gleam"
}
]
}
]
}
},
"scopeName": "markdown.gleam.codeblock"
}

0 comments on commit 6325dd7

Please sign in to comment.