MDX support for Volar
npm install @mdx-js/language-service@mdx-js/language-service[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]
[MDX][] support for [Volar][].
* What is this?
* When should I use this?
* Install
* Use
* API
* [createMdxLanguagePlugin([plugins][, checkMdx][, jsxImportSource])](#createmdxlanguagepluginplugins-checkmdx-jsximportsource)
* createMdxServicePlugin(options)
* resolvePlugins(mdxConfig, resolvePlugin)
* Compatibility
* Types
* Security
* Contribute
* Sponsor
* Changelog
* License
This package implements the logic needed to integrate [MDX][] into [Volar][].
It implements a language plugin which makes Volar understand MDX files.
It also implements a service plugin, which provides some additional
functionality specific to MDX files.
This package is intended for use by
[@mdx-js/language-server][mdx-language-server].
It can also be used with other [Volar][] integrations, such as
[@volar/monaco][volar-monaco].
This package is [ESM only][esm].
In Node.js (version 16+), install with [npm][]:
``sh`
npm install @mdx-js/language-service
In Deno with [esm.sh][esmsh]:
`js`
import {
createMdxLanguagePlugin,
createMdxServicePlugin,
resolvePlugins
} from 'https://esm.sh/@mdx-js/language-service'
In browsers with [esm.sh][esmsh]:
`html`
This package exports functions for use with [Volar][].
See the [API][] documentation for each function to see what it does.
This package exports the identifiers createMdxLanguagePlugin,createMdxServicePlugin, and resolveRemarkPlugins.
There is no default export.
Create a [Volar][] language plugin to support [MDX][].
#### Parameters
* plugins ([PluggableList][pluggablelist], optional) —checkMdx
A list of remark syntax plugins.
Only syntax plugins are supported.
Transformers are unused.
* (boolean, default: false) —jsxImportSource
If true, check MDX files strictly.
* (string, default: react) —
The JSX import source to use in the embedded JavaScript file.
#### Returns
A Volar language plugin to support MDX.
Create a [Volar][] service module to support [MDX][].
The service supports:
* Reporting diagnostics for parsing errors.
* Document drop support for images.
* Custom commands.
The following commands are supported:
* mdx.toggleDelete — Toggle delete syntax at the cursor position.mdx.toggleEmphasis
This takes the URI as its first argument, and the LSP selection range as its
second argument.
* — Toggle emphasis syntax at the cursor position.mdx.toggleInlineCode
This takes the URI as its first argument, and the LSP selection range as its
second argument.
* — Toggle inline code syntax at the cursor position.mdx.toggleStrong
This takes the URI as its first argument, and the LSP selection range as its
second argument.
* — Toggle strong syntax at the cursor position.
This takes the URI as its first argument, and the LSP selection range as its
second argument.
#### Parameters
* options — An object with the following properties:applyEdit
* — A function to apply an LSP workspace edit.
#### Returns
The Volar service plugin for MDX files.
Resolve plugins from TypeScript’s parsed command line options.
#### Parameters
* mdxConfig (unknown) —resolvePlugin
The parsed command line options from which to resolve plugins.
* (Function) —
A function which takes a plugin name, and resolvs it to a remark plugin.
#### Returns
A tuple where the first item is n array of resolved plugins,
or undefined in case of an invalid configuration.
The second item is an array of supported transformer plugins.
The supported transformer plugins are:
* recma-export-filepath
* rehype-mdx-title
* remark-mdx-frontmatter`
This project is compatible Node.js 20.19+.
This package is fully typed with [TypeScript][].
This package provides editor support for [MDX][] files.
Some editor features modify your source code, for example suggestions and
automatic refactors.
It is recommended to keep your source code under version control.
See [§ Contribute][contribute] on our website for ways to get started.
See [§ Support][support] for ways to get help.
This project has a [code of conduct][].
By interacting with this repository, organization, or community you agree to
abide by its terms.
See [§ Sponsor][sponsor] on our site for how to help financially.
Vercel | Motif | HashiCorp | GitBook | Gatsby | |||||
Netlify ![]() | Coinbase | ThemeIsle | Expo | Boost Note ![]() | Markdown Space ![]() | Holloway | |||
You? | |||||||||
Detailed changes for each release are documented in CHANGELOG.md.
[MIT][] © [Remco Haszing][author]
[api]: #api
[author]: https://github.com/remcohaszing
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[build]: https://github.com/mdx-js/mdx-analyzer/actions
[build-badge]: https://github.com/mdx-js/mdx-analyzer/workflows/main/badge.svg
[chat]: https://github.com/mdx-js/mdx/discussions
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[code of conduct]: https://github.com/mdx-js/.github/blob/main/code-of-conduct.md
[collective]: https://opencollective.com/unified
[contribute]: https://mdxjs.com/community/contribute/
[coverage]: https://codecov.io/github/mdx-js/mdx-analyzer
[coverage-badge]: https://img.shields.io/codecov/c/github/mdx-js/mdx-analyzer/main.svg
[downloads]: https://www.npmjs.com/package/@mdx-js/language-service
[downloads-badge]: https://img.shields.io/npm/dm/@mdx-js/language-service.svg
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[esmsh]: https://esm.sh
[mdx]: https://mdxjs.com
[mdx-language-server]: https://github.com/mdx-js/mdx-analyzer/tree/main/packages/language-server
[mit]: LICENSE
[npm]: https://docs.npmjs.com/cli/install
[pluggablelist]: https://github.com/unifiedjs/unified?tab=readme-ov-file#pluggablelist
[size]: https://bundlejs.com/?q=@mdx-js/language-service
[size-badge]: https://img.shields.io/bundlejs/size/@mdx-js/language-service
[sponsor]: https://mdxjs.com/community/sponsor/
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[support]: https://mdxjs.com/community/support/
[typescript]: https://typescriptlang.org
[volar]: https://volarjs.dev
[volar-monaco]: https://github.com/volarjs/volar.js/tree/master/packages/monaco