Skip to content

Commit

Permalink
Add improved syntax highlighting grammar
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wooorm committed Mar 21, 2023
1 parent 7ae33ef commit 6192fc7
Show file tree
Hide file tree
Showing 4 changed files with 6,850 additions and 132 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"packages/*"
],
"scripts": {
"build": "npm --workspaces run build",
"build:monorepo": "cp node_modules/markdown-tm-language/source.mdx.tmLanguage packages/vscode-mdx/syntaxes/",
"build:workspaces": "npm --workspaces run build",
"build": "npm run build:monorepo && npm run build:workspaces",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"start": "npm --workspace @mdx-js/monaco-demo run start",
"test-api": "npm run test-api --workspaces --if-present",
Expand All @@ -16,6 +18,7 @@
"@changesets/changelog-github": "^0.4.0",
"@changesets/cli": "^2.0.0",
"@types/react": "^18.0.0",
"markdown-tm-language": "github:wooorm/markdown-tm-language",
"prettier": "^2.0.0",
"react": "^18.0.0",
"remark-cli": "^11.0.0",
Expand Down
90 changes: 42 additions & 48 deletions packages/vscode-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,55 +86,49 @@
"grammars": [
{
"language": "mdx",
"scopeName": "text.html.markdown.jsx",
"path": "./syntaxes/mdx.tmLanguage.json",
"scopeName": "source.mdx",
"path": "./syntaxes/source.mdx.tmLanguage",
"#1": "note: the below list maps TextMate scopes to VS Code Language IDs (<https://code.visualstudio.com/docs/languages/identifiers>), which does not affect syntax highlighting, but affects for example how comments work.",
"#2": "note: `graphql`, `kotlin`, `toml` have no names in that list, but do work with the most popular extension.",
"#3": "note: we map to JSX-enabled flavors of `js` and `ts`",
"#4": "note: I have no clue how to test `vbnet` (visual basic), I cannot find extensions",
"embeddedLanguages": {
"source.js": "javascript",
"source.js.jsx": "javascriptreact",
"meta.tag.js": "jsx-tags",
"meta.tag.without-attributes.js": "jsx-tags",
"meta.embedded.block.frontmatter": "yaml",
"meta.embedded.block.css": "css",
"meta.embedded.block.ini": "ini",
"meta.embedded.block.java": "java",
"meta.embedded.block.lua": "lua",
"meta.embedded.block.makefile": "makefile",
"meta.embedded.block.perl": "perl",
"meta.embedded.block.r": "r",
"meta.embedded.block.ruby": "ruby",
"meta.embedded.block.php": "php",
"meta.embedded.block.sql": "sql",
"meta.embedded.block.vs_net": "vs_net",
"meta.embedded.block.html": "html",
"meta.embedded.block.xml": "xml",
"meta.embedded.block.xsl": "xsl",
"meta.embedded.block.yaml": "yaml",
"meta.embedded.block.dosbatch": "dosbatch",
"meta.embedded.block.clojure": "clojure",
"meta.embedded.block.coffee": "coffee",
"meta.embedded.block.c": "c",
"meta.embedded.block.cpp": "cpp",
"meta.embedded.block.diff": "diff",
"meta.embedded.block.dockerfile": "dockerfile",
"meta.embedded.block.go": "go",
"meta.embedded.block.groovy": "groovy",
"meta.embedded.block.pug": "jade",
"meta.embedded.block.javascript": "javascript",
"meta.embedded.block.javascriptreact": "javascriptreact",
"meta.embedded.block.json": "json",
"meta.embedded.block.less": "less",
"meta.embedded.block.objc": "objc",
"meta.embedded.block.scss": "scss",
"meta.embedded.block.perl6": "perl6",
"meta.embedded.block.powershell": "powershell",
"meta.embedded.block.python": "python",
"meta.embedded.block.rust": "rust",
"meta.embedded.block.scala": "scala",
"meta.embedded.block.shellscript": "shellscript",
"meta.embedded.block.typescript": "typescript",
"meta.embedded.block.typescriptreact": "typescriptreact",
"meta.embedded.block.csharp": "csharp",
"meta.embedded.block.fsharp": "fsharp"
"meta.embedded.c": "c",
"meta.embedded.cpp": "cpp",
"meta.embedded.cs": "csharp",
"meta.embedded.css": "css",
"meta.embedded.diff": "diff",
"meta.embedded.go": "go",
"meta.embedded.graphql": "graphql",
"meta.embedded.html": "html",
"meta.embedded.ini": "ini",
"meta.embedded.java": "java",
"meta.embedded.js": "javascriptreact",
"meta.embedded.json": "json",
"meta.embedded.kotlin": "kotlin",
"meta.embedded.less": "less",
"meta.embedded.lua": "lua",
"meta.embedded.makefile": "makefile",
"meta.embedded.md": "markdown",
"meta.embedded.mdx": "mdx",
"meta.embedded.objc": "objective-c",
"meta.embedded.perl": "perl",
"meta.embedded.php": "php",
"meta.embedded.python": "python",
"meta.embedded.r": "r",
"meta.embedded.ruby": "ruby",
"meta.embedded.rust": "rust",
"meta.embedded.scss": "scss",
"meta.embedded.shell": "shellscript",
"meta.embedded.sql": "sql",
"meta.embedded.svg": "xml",
"meta.embedded.swift": "swift",
"meta.embedded.toml": "toml",
"meta.embedded.ts": "typescriptreact",
"meta.embedded.tsx": "typescriptreact",
"meta.embedded.vbnet": "vb",
"meta.embedded.xml": "xml",
"meta.embedded.yaml": "yaml"
}
}
]
Expand Down
83 changes: 0 additions & 83 deletions packages/vscode-mdx/syntaxes/mdx.tmLanguage.json

This file was deleted.

Loading

0 comments on commit 6192fc7

Please sign in to comment.