Skip to content

Commit

Permalink
syntax highlight for svelte block in markdown (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonlyu123 committed Jul 10, 2020
1 parent cc6cac0 commit 514187d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/svelte-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@
"source.js": "javascript",
"source.ts": "typescript"
}
},
{
"scopeName": "markdown.svelte.codeblock",
"path": "./syntaxes/markdown-svelte.json",
"injectTo": [
"text.html.markdown"
],
"embeddedLanguages": {
"meta.embedded.block.svelte": "svelte"
}
}
],
"commands": [
Expand Down
45 changes: 45 additions & 0 deletions packages/svelte-vscode/syntaxes/markdown-svelte.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"scopeName": "markdown.svelte.codeblock",
"fileTypes": [],
"injectionSelector": "L:text.html.markdown",
"patterns": [
{
"include": "#svelte-code-block"
}
],
"repository": {
"svelte-code-block": {
"begin": "(^|\\G)(\\s*)(\\`{3,}|~{3,})\\s*(?i:(svelte|sv)(\\s+[^`~]*)?$)",
"name": "markup.fenced_code.block.markdown",
"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
"beginCaptures": {
"3": {
"name": "punctuation.definition.markdown"
},
"5": {
"name": "fenced_code.block.language"
},
"6": {
"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.svelte",
"patterns": [
{
"include": "source.svelte"
}
]
}
]
}
}
}

0 comments on commit 514187d

Please sign in to comment.