-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add improved syntax highlighting grammar (#317)
This now pulls in a grammar for from: <https://github.com/wooorm/markdown-tm-language>. It fixes a bunch of previous errors and adds real support for MDX. It also supports YAML frontmatter, TOML frontmatter, GFM (autolink literals, footnotes, strikethrough, tables, tasklists), GitHub (gemoji, mentions, references). There’s support for about 20 common embedded grammars in fenced code blocks. Embedded code (in fenced code blocks, or in ESM/expressions) is now marked as being the correct language, which makes comments and such work. Closes GH-183. Closes GH-191. Closes GH-209. Closes GH-221. Co-authored-by: Remco Haszing <[email protected]>
- Loading branch information
1 parent
7ae33ef
commit f1bd49b
Showing
12 changed files
with
6,936 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
'vscode-mdx': minor | ||
--- | ||
|
||
Add improved syntax highlighting grammar | ||
|
||
This now pulls in a grammar for from: | ||
<https://github.com/wooorm/markdown-tm-language>. | ||
|
||
It fixes a bunch of previous errors and adds real support for MDX. | ||
It also supports YAML frontmatter, TOML frontmatter, GFM (autolink | ||
literals, footnotes, strikethrough, tables, tasklists), GitHub (gemoji, | ||
mentions, references). | ||
There’s support for about 20 common embedded grammars in fenced code | ||
blocks. | ||
Embedded code (in fenced code blocks, or in ESM/expressions) is now | ||
marked as being the correct language, which makes comments and such | ||
work. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*.d.ts | ||
*.d.mts | ||
*.log | ||
*.tgz | ||
*.tsbuildinfo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ demo/ | |
fixtures/ | ||
node_modules/ | ||
packages/ | ||
script/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env node | ||
import assert from 'node:assert/strict' | ||
import fs from 'node:fs/promises' | ||
import {fetch} from 'undici' | ||
|
||
const repo = 'wooorm/markdown-tm-language' | ||
const branch = 'main' | ||
const filename = 'source.mdx.tmLanguage' | ||
|
||
const branchesResponse = await fetch( | ||
`https://api.github.com/repos/${repo}/branches` | ||
) | ||
|
||
const branches = | ||
/** @type {Array<{name: string, commit: {sha: string, url: string}, protected: boolean}>} */ ( | ||
await branchesResponse.json() | ||
) | ||
const main = branches.find((d) => d.name === branch) | ||
assert(main, 'expected `' + branch + '` branch') | ||
|
||
const sha = main.commit.sha | ||
|
||
const blobResponse = await fetch( | ||
`https://raw.githubusercontent.com/${repo}/${branch}/${filename}` | ||
) | ||
let blob = await blobResponse.text() | ||
|
||
let injected = false | ||
|
||
blob = blob.replace(/<dict>/, ($0) => { | ||
injected = true | ||
return `<!-- | ||
This file is maintained at <https://github.com/${repo}/blob/${branch}/${filename}>. | ||
To improve it, please create a pull request to the original repository. | ||
Once accepted there, it can be pulled into this project (\`vscode-mdx\`) with | ||
\`script/build.js\`, and released. | ||
Version from SHA: ${sha}. | ||
--> | ||
${$0}` | ||
}) | ||
|
||
assert(injected, 'expected to find a dict') | ||
|
||
await fs.writeFile( | ||
new URL('../syntaxes/source.mdx.tmLanguage', import.meta.url), | ||
blob | ||
) | ||
|
||
console.log('Wrote `source.mdx.tmLanguage` at `' + sha + '`') |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.