unified

Project: micromark/micromark-extension-mdx-md

Package: micromark-extension-mdx-md@1.0.0

  1. Dependents: 0
  2. micromark extension to turn some markdown features off for MDX
  1. unified 181
  2. markdown 145
  3. mdx 36
  4. micromark 35
  5. micromark-extension 17
  6. mdxjs 9
  7. md 4

micromark-extension-mdx-md

Build Coverage Downloads Size Sponsors Backers Chat

micromark extension to turn some markdown features off for MDX.

Contents

What is this?

This package contains an extension to turn off some markdown constructs when parsing.

When to use this

These tools are all low-level. In many cases, you want to use remark-mdx with remark instead. When you are using mdx-js/mdx, that is already included.

Even when you want to use micromark, you likely want to use micromark-extension-mdxjs to support all MDX features. That extension includes this extension.

Install

This package is ESM only. In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with npm:

npm install micromark-extension-mdx-md

In Deno with esm.sh:

import {mdxMd} from 'https://esm.sh/micromark-extension-mdx-md@1'

In browsers with esm.sh:

<script type="module">
  import {mdxMd} from 'https://esm.sh/micromark-extension-mdx-md@1?bundle'
</script>

Use

import {micromark} from 'micromark'
import {mdxMd} from 'micromark-extension-mdx-md'

const output = micromark('\ta', {extensions: [mdxMd]})

console.log(output)

Yields:

<p>a</p>

API

This package exports the identifier mdxMd. There is no default export.

mdxMd

Syntax extension for micromark (passed in extensions).

Authoring

To improve authoring MDX, and the new constructs it adds (JSX, expressions, and ESM), some markdown features are turned off. This extension does that.

It turns off:

Code (indented)

Use fenced code instead. Change the following markdown:

    console.log(1)

…into:

```js
console.log(1)
```

Use links (with a resource or a reference) instead. Change the following markdown:

<https://some-link-here.com>

…into:

[descriptive text](https://and-the-link-here.com)
HTML (flow and text)

Use JSX instead: change <img> into <img />. Not supporting HTML also means that HTML comments are not supported. Use a comment in an empty expression instead. Change <!-- comment --> into {/* comment */}.

Types

This package is fully typed with TypeScript. It exports no additional types.

Compatibility

This package is at least compatible with all maintained versions of Node.js. As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+. It also works in Deno and modern browsers.

Security

This package is safe.

Contribute

See contributing.md in micromark/.github for ways to get started. See support.md 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.

License

MIT © Titus Wormer