VOOZH about

URL: https://marketplace.visualstudio.com/items?itemName=unifiedjs.vscode-mdx

⇱ MDX - Visual Studio Marketplace


Skip to content
πŸ‘ Image
Sign in
πŸ‘ MDX

MDX

Language support for MDX
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

MDX for Visual Studio Code

πŸ‘ Build
πŸ‘ Coverage
πŸ‘ Visual Studio Marketplace Downloads
πŸ‘ Open VSX Downloads
πŸ‘ Sponsors
πŸ‘ Backers
πŸ‘ Chat

Visual Studio Code extension to add language support for MDX.

Contents

Install

Get it on the VS Code Marketplace or install it by using Quick Open (Ctrl + P) and running the following:

ext install unifiedjs.vscode-mdx

Settings

All MDX language server configurations can be configured via Visual Studio Code settings. MDX for VSCode supports the following additional setting:

  • mdx.server.enable (boolean, default: true) β€” Enable the MDX language server.

TypeScript

This extension offers type safety for MDX files based on TypeScript’s types in JSDoc. For MDX specific details, see the TypeScript section of the repository readme.

Plugins

For information on plugin support, see the Plugins section of the repository readme.

Syntax highlighting

Syntax highlighting for MDX is based on the MDX TextMate grammar.

Custom Languages in Code Blocks

MDX for Visual Studio Code supports syntax highlighting for a number of well-known languages in code blocks. However, it’s impossible to support all languages within the MDX extension. Instead, if an extensions adds support for a language, it can add support for MDX code blocks.

The following example adds support for syntax highlighting MDX code blocks tagged with mermaid. You can use this example and replace mermaid with the appropriate values to support your own language. Save the file to syntaxes/mdx.mermaid.tmLanguage.json.

{
 "fileTypes": [],
 // This can be something else.
 "scopeName": "mdx.mermaid.codeblock",
 "injectionSelector": "L:source.mdx",
 "patterns": [
 {
 "begin": "(?:^|\\G)[\\t ]*(`{3,})(?:[\\t ]*((?i:(?:.*\\.)?mermaid))(?:[\\t ]+((?:[^\\n\\r`])+))?)(?:[\\t ]*$)",
 "beginCaptures": {
 "1": {
 "name": "string.other.begin.code.fenced.mdx"
 },
 "2": {
 "name": "entity.name.function.mdx"
 }
 },
 "contentName": "meta.embedded.mermaid",
 "end": "(\\1)(?:[\\t ]*$)",
 "endCaptures": {
 "1": {
 "name": "string.other.end.code.fenced.mdx"
 }
 },
 "name": "markup.code.mermaid.mdx",
 "patterns": [
 {
 "include": "source.mermaid"
 }
 ]
 },
 {
 "begin": "(?:^|\\G)[\\t ]*(~{3,})(?:[\\t ]*((?i:(?:.*\\.)?mermaid))(?:[\\t ]+((?:[^\\n\\r])+))?)(?:[\\t ]*$)",
 "beginCaptures": {
 "1": {
 "name": "string.other.begin.code.fenced.mdx"
 },
 "2": {
 "name": "entity.name.function.mdx"
 }
 },
 "contentName": "meta.embedded.mermaid",
 "end": "(\\1)(?:[\\t ]*$)",
 "endCaptures": {
 "1": {
 "name": "string.other.end.code.fenced.mdx"
 }
 },
 "name": "markup.code.mermaid.mdx",
 "patterns": [
 {
 "include": "source.mermaid"
 }
 ]
 }
 ]
}

In package.json, add the following section. Replace mermaid with your actual language and remove comments.

{
 "contributes": {
 "grammars": [
 {
 // This must match the scopeName in the tmLanguage file.
 "scopeName": "mdx.mermaid.codeblock",
 "path": "./syntaxes/mdx.mermaid.tmLanguage.json",
 "injectTo": [
 "source.mdx"
 ],
 "embeddedLanguages": {
 "source.mermaid": "mermaid",
 }
 }
 ]
 }
}

ESLint

You can lint MDX with ESLint using eslint-plugin-mdx. To integrate ESLint in Visual Studio Code, install the VS Code ESLint extension.

Auto-close tags

If you want VS Code to automatically close tags while you type, install Auto Close Tag and configure it to also include the mdx language:

{
 "auto-close-tag.activationOnLanguage": [
 // …
 "mdx"
 ]
}

Prettier

Prettier supports MDX 1, but MDX 2 and 3 are not officially supported yet. We recommend against formatting MDX files with Prettier. To opt out, add the following line to your .prettierignore file:

*.mdx

Sponsor

See Β§ Sponsor on our site for how to help financially.

Vercel

πŸ‘ Image
Motif

πŸ‘ Image
HashiCorp

πŸ‘ Image
GitBook

πŸ‘ Image
Gatsby

πŸ‘ Image
Netlify

πŸ‘ Image
Coinbase

πŸ‘ Image
ThemeIsle

πŸ‘ Image
Expo

πŸ‘ Image
Boost Note

πŸ‘ Image
Markdown Space

πŸ‘ Image
Holloway

πŸ‘ Image

You?

Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT Β© JounQin@1stG.me