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.
npm install markdown-exitpnpm add markdown-exityarn add markdown-exitbun add markdown-exit<script type="module">
import { createMarkdownExit } from 'https://esm.sh/markdown-exit';
const md = createMarkdownExit();
const html = md.render('# markdown-exit');
</script>Version Compatibility
| markdown-exit | markdown-it | Status |
|---|---|---|
v2.0+ (latest) | v15.0+ | Actively maintained |
v1.x | v14.x | Superseded — see Migration to v2 |
v0.x (legacy) | v14.3.0 | No 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:
npm install markdown-exit@legacypnpm add markdown-exit@legacyyarn add markdown-exit@legacybun add markdown-exit@legacy<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:
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:
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.
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:
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:
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 callingmd.use(). - If any module in your app imports
markdown-exitinstead ofmarkdown-exit/core, linkify-it is bundled anyway, and instances created frommarkdown-exit/coreget a linkify-it instance too.