micromark-extension-mdx-md

micromark extension to turn some markdown features off for MDX

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
micromark-extension-mdx-md
102.0.010 months ago3 years agoMinified + gzip package size for micromark-extension-mdx-md in KB

Readme

micromark-extension-mdx-md
!Buildbuild-badgebuild !Coveragecoverage-badgecoverage !Downloadsdownloads-badgedownloads !Sizesize-badgesize !Sponsorssponsors-badgecollective !Backersbackers-badgecollective !Chatchat-badgechat
micromark extension to turn some markdown features off for MDXmdxjs.

Contents

*   [`mdxMd()`](#mdxmd)

What is this?

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

When to use this

This project is useful when you want to disable support for code (indented), autolinks, and HTML (flow and text) in markdown.
You can use this extension when you are working with micromarkmicromark. To support all MDX features, use micromark-extension-mdxjsmicromark-extension-mdxjs instead.
All these packages are used in remark-mdxremark-mdx, which focusses on making it easier to transform content by abstracting these internals away.

Install

This package is ESM onlyesm. In Node.js (version 16+), install with npm:
npm install micromark-extension-mdx-md

In Deno with esm.shesmsh:
import {mdxMd} from 'https://esm.sh/micromark-extension-mdx-md@2'

In browsers with esm.shesmsh:
<script type="module">
  import {mdxMd} from 'https://esm.sh/micromark-extension-mdx-md@2?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 mdxMdapi-mdx-md. There is no default export.

mdxMd()

Create an extension for micromark to disable some CommonMark syntax (code (indented), autolinks, and HTML (flow and text)) for MDX.
Returns
Extension for micromark that can be passed in extensions to disable some CommonMark syntax for MDX (Extensionmicromark-extension).

Authoring

To improve authoring the new constructs MDX adds (ESM, expressions, and JSX), some markdown features are turned off by this extension. There are good alternatives.
Code (indented)
Use fenced code instead. Change the following markdown:
console.log(1)

…into:
````markdown
console.log(1)
````
Autolinks
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

Projects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of Node. This means we try to keep the current release line, micromark-extension-mdx-md@^2, compatible with Node.js 16. This package works with micromark@^3.

Security

This package is safe.

Related

— support all of MDX
— support all of MDX in remark

Contribute

See contributing.md in micromark/.githubcontributing for ways to get started. See support.mdsupport for ways to get help.
This project has a code of conductcoc. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MITlicense © Titus Wormerauthor