Skip to content

Commit

Permalink
feat(vscode): enable syntax highlighting of cue code blocks in MDX
Browse files Browse the repository at this point in the history
This enables syntax highlighting of code blocks inside MDX files
annotated with the `vue` language.
  • Loading branch information
remcohaszing committed May 30, 2024
1 parent b80b63a commit d17c6cf
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
36 changes: 36 additions & 0 deletions extensions/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,42 @@
"source.graphql": "graphql"
}
},
{
"scopeName": "mdx.vue.codeblock",
"path": "./syntaxes/mdx-vue.json",
"injectTo": [
"source.mdx"
],
"embeddedLanguages": {
"mdx.embedded.vue": "vue",
"source.vue": "vue",
"text": "plaintext",
"text.html.derivative": "html",
"text.html.markdown": "markdown",
"text.pug": "jade",
"source.css": "css",
"source.css.scss": "scss",
"source.css.less": "less",
"source.sass": "sass",
"source.stylus": "stylus",
"source.postcss": "postcss",
"source.js": "javascript",
"source.ts": "typescript",
"source.js.jsx": "javascriptreact",
"source.tsx": "typescriptreact",
"source.coffee": "coffeescript",
"meta.tag.js": "jsx-tags",
"meta.tag.tsx": "jsx-tags",
"meta.tag.without-attributes.js": "jsx-tags",
"meta.tag.without-attributes.tsx": "jsx-tags",
"source.json": "json",
"source.json.comments": "jsonc",
"source.json5": "json5",
"source.yaml": "yaml",
"source.toml": "toml",
"source.graphql": "graphql"
}
},
{
"scopeName": "vue.directives",
"path": "./syntaxes/vue-directives.json",
Expand Down
70 changes: 70 additions & 0 deletions extensions/vscode/syntaxes/mdx-vue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"fileTypes": [ ],
"scopeName": "mdx.vue.codeblock",
"injectionSelector": "L:source.mdx",
"patterns": [
{
"include": "#vue-code-block"
}
],
"repository": {
"vue-code-block": {
"patterns": [
{
"begin": "(?:^|\\G)[\\t ]*(`{3,})(?:[\\t ]*((?i:(?:.*\\.)?vue))(?:[\\t ]+((?:[^\\n\\r`])+))?)(?:[\\t ]*$)",
"beginCaptures": {
"1": {
"name": "string.other.begin.code.fenced.mdx"
},
"2": {
"name": "entity.name.function.mdx"
}
},
"contentName": "meta.embedded.vue",
"end": "(\\1)(?:[\\t ]*$)",
"endCaptures": {
"1": {
"name": "string.other.end.code.fenced.mdx"
}
},
"name": "markup.code.vue.mdx",
"patterns": [
{
"begin": "(^|\\G)(\\s*)(.*)",
"while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)",
"patterns": [
{
"include": "source.vue"
}
]
}
]
},
{
"begin": "(?:^|\\G)[\\t ]*(~{3,})(?:[\\t ]*((?i:(?:.*\\.)?vue))(?:[\\t ]+((?:[^\\n\\r])+))?)(?:[\\t ]*$)",
"beginCaptures": {
"1": {
"name": "string.other.begin.code.fenced.mdx"
},
"2": {
"name": "entity.name.function.mdx"
}
},
"contentName": "meta.embedded.vue",
"end": "(\\1)(?:[\\t ]*$)",
"endCaptures": {
"1": {
"name": "string.other.end.code.fenced.mdx"
}
},
"name": "markup.code.vue.mdx",
"patterns": [
{
"include": "source.vue"
}
]
}
]
}
}
}

0 comments on commit d17c6cf

Please sign in to comment.