Skip to content

Commit

Permalink
fix: Update Astro syntax highlighting for MDX files (#950)
Browse files Browse the repository at this point in the history
* fix: Update Astro syntax highlighting for MDX files

* add changeset
  • Loading branch information
liruifengv authored Sep 6, 2024
1 parent af5bbc5 commit 572e9cb
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 62 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-coats-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro-vscode": patch
---

Fix Astro codeblock syntax highlighting for MDX files
5 changes: 3 additions & 2 deletions packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,14 @@
}
},
{
"scopeName": "text.mdx.astro.codeblock",
"scopeName": "source.mdx.astro",
"path": "./syntaxes/mdx.astro.tmLanguage.json",
"injectTo": [
"source.mdx"
],
"embeddedLanguages": {
"mdx.embedded.astro": "astro"
"mdx.embedded.astro": "astro",
"mdx.embedded.astro.frontmatter": "typescriptreact"
}
}
]
Expand Down
97 changes: 37 additions & 60 deletions packages/vscode/syntaxes/mdx.astro.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -1,84 +1,61 @@
{
"fileTypes": [],
"scopeName": "text.mdx.astro.codeblock",
"scopeName": "source.mdx.astro",
"injectionSelector": "L:source.mdx",
"patterns": [
{
"begin": "(?:^|\\G)[\\t ]*(`{3,})(?:[\\t ]*((?i:(?:.*\\.)?astro))(?:[\\t ]+((?:[^\\n\\r`])+))?)(?:[\\t ]*$)",
"beginCaptures": {
"1": {
"name": "string.other.begin.code.fenced.mdx"
},
"2": {
"name": "entity.name.function.mdx"
}
},
"contentName": "meta.embedded.astro",
"end": "(\\1)(?:[\\t ]*$)",
"endCaptures": {
"1": {
"name": "string.other.end.code.fenced.mdx"
}
},
"name": "markup.code.astro.mdx",
"patterns": [
{
"include": "#astro-code-block"
}
]
},
{
"begin": "(?:^|\\G)[\\t ]*(~{3,})(?:[\\t ]*((?i:(?:.*\\.)?astro))(?:[\\t ]+((?:[^\\n\\r])+))?)(?:[\\t ]*$)",
"include": "#mdx_fenced_code_block_astro"
}
],
"repository": {
"mdx_fenced_code_block_astro": {
"begin": "(?:^|\\G)[\\t ]*([`~]{3,})(?:[\\t ]*((?:astro|(?:.*\\.)?(?:astro)))(?:[\\t ]+((?:[^\\n\\r`])+))?)(?:[\\t ]*$)",
"beginCaptures": {
"1": {
"name": "string.other.begin.code.fenced.mdx"
"name": "punctuation.definition.markdown"
},
"2": {
"name": "entity.name.function.mdx"
"name": "entity.name.function.markdown"
}
},
"contentName": "meta.embedded.astro",
"end": "(\\1)(?:[\\t ]*$)",
"end": "(^\\1)\\s*$",
"endCaptures": {
"1": {
"name": "string.other.end.code.fenced.mdx"
"3": {
"name": "punctuation.definition.markdown"
}
},
"name": "markup.code.astro.mdx",
"patterns": [
{
"include": "#astro-code-block"
}
]
}
],
"repository": {
"astro-code-block": {
"patterns": [
{
"begin": "^\\s*---\\s*$",
"end": "^\\s*---\\s*$",
"beginCaptures": {
"0": {
"name": "punctuation.definition.tag.xi.begin.t"
}
},
"endCaptures": {
"0": {
"name": "punctuation.definition.tag.xi.end.t"
}
},
"contentName": "meta.embedded.block.astro.frontmatter",
"begin": "(^|\\G)(\\s*)(.*)",
"while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)",
"patterns": [
{
"include": "source.tsx"
"begin": "^\\s*---\\s*$",
"end": "^\\s*---\\s*$",
"beginCaptures": {
"0": {
"name": "punctuation.definition.tag.xi.begin.t"
}
},
"endCaptures": {
"0": {
"name": "punctuation.definition.tag.xi.end.t"
}
},
"contentName": "mdx.embedded.astro.frontmatter",
"patterns": [
{
"include": "source.tsx"
}
]
},
{
"contentName": "mdx.embedded.astro",
"include": "source.astro"
}
]
},
{
"include": "source.astro"
}
]
}
}
}
}

0 comments on commit 572e9cb

Please sign in to comment.