Skip to content
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

Merged
merged 3 commits into from
Jun 4, 2024

Conversation

remcohaszing
Copy link
Member

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

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.

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.
@remcohaszing remcohaszing added 📚 area/docs This affects documentation 🦋 type/enhancement This is great to have 👶 semver/patch This is a backwards-compatible fix 👍 phase/yes Post is accepted and can be worked on labels May 30, 2024
Copy link

changeset-bot bot commented May 30, 2024

🦋 Changeset detected

Latest commit: 37615ee

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
vscode-mdx Patch

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.

packages/vscode-mdx/README.md Outdated Show resolved Hide resolved
"name": "markup.code.LANGUAGE.mdx",
"patterns": [
{
"include": "source.LANGUAGE"
Copy link
Member

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?

Copy link
Member Author

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"
  // }
]

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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

Copy link
Member Author

@remcohaszing remcohaszing Jun 4, 2024

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.
@remcohaszing remcohaszing merged commit f600a05 into main Jun 4, 2024
8 checks passed
@remcohaszing remcohaszing deleted the docs-code-block-highlighting branch June 4, 2024 11:06

This comment has been minimized.

@github-actions github-actions bot mentioned this pull request Jun 4, 2024
@remcohaszing remcohaszing added the 💪 phase/solved Post is done label Jun 4, 2024
@github-actions github-actions bot removed the 👍 phase/yes Post is accepted and can be worked on label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 area/docs This affects documentation 💪 phase/solved Post is done 👶 semver/patch This is a backwards-compatible fix 🦋 type/enhancement This is great to have
Development

Successfully merging this pull request may close these issues.

2 participants