-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document syntax highlighting for MDX code blocks #444
Conversation
MDX syntax highlighting can’t possibly support all past, present, and future languages in code blocks. Extensions can inject their own syntax highlighting. This documentation helps extension authors to support their own language in MDX code blocks.
🦋 Changeset detectedLatest commit: 37615ee The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This comment has been minimized.
This comment has been minimized.
packages/vscode-mdx/README.md
Outdated
"name": "markup.code.LANGUAGE.mdx", | ||
"patterns": [ | ||
{ | ||
"include": "source.LANGUAGE" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not all languages are source.*
, perhaps use another variable name, SCOPE
or so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Astro it’s even more complex. Perhaps I should write something like:
"patterns": [
// Your patterns, typically something like:
// {
// "include": "source.LANGUAGE"
// }
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, just use a practical example. Such as the mermaid one. And then tell people: change it to the needs of your language.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean to replace LANGUAGE
with mermaid
throughout the entire example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah something along those lines: say something along the lines of “here’s how Mermaid injects itself into MDX, which you can use as inspiration when doing similar things” and then the code blocks, with actual working code for mermaid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. IMO it’s neither better nor worse.
The actual Mermaid example implementation slightly different, because they use a build script to include the entire YAML language within the injection. But this exact example would have worked too, it’s what I generally recommend.
It’s unnecessary complexity for such a simple case.
This example is more real.
Initial checklist
Description of changes
MDX syntax highlighting can’t possibly support all past, present, and future languages in code blocks. Extensions can inject their own syntax highlighting.
This documentation helps extension authors to support their own language in MDX code blocks.