Skip to content

Commit

Permalink
feat(vscode): enable syntax highlighting of cue code blocks in MDX (v…
Browse files Browse the repository at this point in the history
…uejs#4425)

This enables syntax highlighting of code blocks inside MDX files
annotated with the `vue` language.
  • Loading branch information
remcohaszing authored and tl committed Jun 18, 2024
1 parent bcde5fe commit bd842da
Show file tree
Hide file tree
Showing 2 changed files with 100 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 @@ -176,6 +176,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
64 changes: 64 additions & 0 deletions extensions/vscode/syntaxes/mdx-vue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"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": [
{
"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 bd842da

Please sign in to comment.