Skip to content

Quick Start ​

Installation ​

markdown-exit v2.0+ (latest) supports markdown-it v15.0+ and its plugins, and adds new capabilities such as async rendering along with performance improvements.

sh
npm install markdown-exit
sh
pnpm add markdown-exit
sh
yarn add markdown-exit
sh
bun add markdown-exit
html
<script type="module">
import { createMarkdownExit } from 'https://esm.sh/markdown-exit';

const md = createMarkdownExit();
const html = md.render('# markdown-exit');
</script>

Version Compatibility ​

markdown-exitmarkdown-itStatus
v2.0+ (latest)v15.0+Actively maintained
v1.xv14.xSuperseded — see Migration to v2
v0.x (legacy)v14.3.0No longer maintained

Legacy Version (v0.x) ​

No longer maintained

The legacy branch (v0.x) is no longer maintained. Its final release is v0.5.0, which tracks markdown-it v14.3.0.

v0.x was created to bring TypeScript typings to markdown-it. Since markdown-it has been rewritten in TypeScript as of v15, you can now use markdown-it directly if native typings are all you need.

If you are looking for markdown-it v15.0+ support together with async rendering, other new features and performance improvements, upgrade to markdown-exit v2.0+ instead.

The final legacy release is still available on npm:

sh
npm install markdown-exit@legacy
sh
pnpm add markdown-exit@legacy
sh
yarn add markdown-exit@legacy
sh
bun add markdown-exit@legacy
html
<script type="module">
import { createMarkdownExit } from 'https://esm.sh/markdown-exit@legacy';

const md = createMarkdownExit();
const html = md.render('# markdown-exit');
</script>

Usage ​

Named import (recommended)

Use createMarkdownExit to create an instance:

ts
import { createMarkdownExit } from 'markdown-exit'

// factory helper
const md = createMarkdownExit()
md.render('# markdown-exit')

Rendering

Please refer to the Rendering guide for more details on rendering Markdown content.

If you prefer using the MarkdownExit class with new, you can do so as follows:

ts
import { MarkdownExit } from 'markdown-exit'

// with the `new` keyword
const md = new MarkdownExit()

Default import (with callable constructor support) is retained for markdown-it compatibility, but it may have drawbacks in module interop and tree-shaking. We do not recommend using it in modern codebases.

ts
import MarkdownExit from 'markdown-exit'

// callable function
const md = MarkdownExit()

// OR with the `new` keyword
const md = new MarkdownExit()

Core Entry ​

markdown-exit/core exposes the same API as markdown-exit, but leaves out linkify-it, the library behind the linkify option. If you never enable linkify, import from markdown-exit/core to get a smaller bundle:

ts
import { createMarkdownExit } from 'markdown-exit/core'

const md = createMarkdownExit()
md.render('https://example.com') // <p>https://example.com</p>

In the core entry, md.linkify is undefined. To enable linkify, install linkify-it and assign an instance yourself:

ts
import { LinkifyIt } from 'linkify-it'
import { createMarkdownExit } from 'markdown-exit/core'

const md = createMarkdownExit({ linkify: true })
md.linkify = new LinkifyIt()

WARNING

  • Plugins that access md.linkify (e.g. md.linkify.set(...)) throw in the core entry unless you assign a linkify-it instance before calling md.use().
  • If any module in your app imports markdown-exit instead of markdown-exit/core, linkify-it is bundled anyway, and instances created from markdown-exit/core get a linkify-it instance too.

Released under the MIT License.