package
A PostHTML plugin to transform Markdown using markdown-it
npm install posthtml-markdownitGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
This PostHTML plugin compiles Markdown to HTML using markdown-it.
Before:
<markdown>
# Heading 1
---
Paragraph with some text
_Italic_
**Bold**
- List item 1
- List item 2
- List item 3
</markdown>After:
<h1>Heading 1</h1>
<hr>
<p>Paragraph with some text</p>
<p>
<em>Italic</em>
<strong>Bold</strong>
</p>
<ul>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
npm i -D posthtml posthtml-markdownitimport posthtml from 'posthtml'
import markdown from 'posthtml-markdownit'
posthtml([
markdown()
])
.process('<markdown># Test</markdown>')
.then(result => console.log(result.html))
// <h1>Test</h1>You can import and render Markdown files:
Before:
<markdown src="./README.md">
# Imported
</markdown>After:
<!-- Here be the contents of README.md, as HTML -->
<h1>Imported</h1>Both <markdown> and <md> tags are supported.
Before:
<md>
# Heading 1
</md>After:
<h1>Heading 1</h1>By default, the custom tags like <md> are replaced with the compiled Markdown. See the tag attribute if you need a wrapping tag around your Markdown content.
You can also use the markdown or md attributes on an HTML element:
Before:
<div md>
# Heading 1
</div>After:
<h1>Heading 1</h1>tagYou can use a tag attribute to wrap the resulting markup in a tag:
Before:
<md tag="section">
# Heading 1
</md>After:
<section>
<h1>Heading 1</h1>
</section>inlineYou can mark the content to be rendered inline. This is helpful if you're including a file that will be used as an inline element and don't want the enclosing p tags.
Before:
<div class="example">
<markdown src="./example.md" inline>
Imported
</markdown>
</div>After:
<p class="example">Imported</p>Instead of:
<div class="example">
<p>Imported</p>
</div>rootType: string
Default: ./
A path relative to which Markdown files will be imported.
encodingType: string
Default: utf8
Encoding for imported Markdown files.
markdownitType: object
Default: {}
Options passed to the markdown-it library. See the available options.
pluginsType: array
Default: []
Plugins for markdown-it.
Example:
import {light as emoji} from 'markdown-it-emoji'
markdown({
plugins: [{
plugin: emoji,
options: {} // Options for markdown-it-emoji
}]
})thecomputerm
mudit.somani00@outlook.com
Estimated unpacked size across 17 packages.
3.2 MB
Includes dependencies.
5 direct · 2 outdated
^0.16.6
0.16.7
^1.0.0
1.0.1
^14.0.0
15.0.3
^0.12.0
0.13.0
^3.0.0
3.0.0