
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
posthtml-markdownit
Advanced tools
This PostHTML plugin converts 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>
</ul>
$ npm i -D posthtml posthtml-markdownit
const posthtml = require('posthtml')
const markdown = require('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:
<!-- 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 tags are removed. 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>
tag
You 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>
inline
You 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>
root
Type: string
Default: ./
A path relative to which markdown files are imported.
encoding
Type: string
Default: utf8
Encoding for imported Markdown files.
markdownit
Type: object
Default: {}
Options passed to markdown-it. See the available options.
plugins
Type: array
Default: []
Plugins for markdown-it.
Example:
const {light: emoji} = require('markdown-it-emoji')
markdown({
plugins: [{
plugin: emoji,
options: {} // Options for markdown-it-emoji
}]
})
FAQs
A PostHTML plugin to transform Markdown using markdown-it
The npm package posthtml-markdownit receives a total of 17,568 weekly downloads. As such, posthtml-markdownit popularity was classified as popular.
We found that posthtml-markdownit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.