Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
remark-rehype
Advanced tools
The remark-rehype npm package is a plugin that transforms Markdown (.md) files into HTML. It is part of the unified ecosystem and is commonly used to integrate with other unified plugins to process and manipulate content.
Markdown to HTML conversion
This feature allows you to convert Markdown content into HTML. The code sample demonstrates how to set up a unified processor that parses Markdown, converts it to HTML using remark-rehype, and then serializes it to a string.
const unified = require('unified');
const markdown = require('remark-parse');
const remark2rehype = require('remark-rehype');
const html = require('rehype-stringify');
unified()
.use(markdown)
.use(remark2rehype)
.use(html)
.process('# Hello world!', function (err, file) {
if (err) throw err;
console.log(String(file));
});
Integration with unified ecosystem
remark-rehype can be used in conjunction with other plugins in the unified ecosystem, such as rehype-format for formatting the resulting HTML. The code sample shows how to include the rehype-format plugin in the processing pipeline.
const unified = require('unified');
const markdown = require('remark-parse');
const remark2rehype = require('remark-rehype');
const rehypeFormat = require('rehype-format');
const html = require('rehype-stringify');
unified()
.use(markdown)
.use(remark2rehype)
.use(rehypeFormat)
.use(html)
.process('# Hello world!', function (err, file) {
if (err) throw err;
console.log(String(file));
});
remark-html is a remark plugin to compile Markdown to HTML. It is similar to remark-rehype but does not use the rehype ecosystem, which means it has less flexibility in terms of further HTML manipulations.
Showdown is a JavaScript Markdown to HTML converter, which can be used on both the server and in the browser. Unlike remark-rehype, it is not part of the unified ecosystem and operates as a standalone converter.
Bridge / mutate from remark to rehype.
npm:
npm install remark-rehype
var unified = require('unified');
var parse = require('remark-parse');
var remark2rehype = require('remark-rehype');
var highlight = require('rehype-highlight');
var stringify = require('rehype-stringify');
var report = require('vfile-reporter');
unified()
.use(parse)
.use(remark2rehype)
.use(highlight)
.use(stringify)
.process([
'## Hello, world!',
'',
' "use strict"',
' var name = "World";',
' console.log("Hello, " + name + "!");',
''
].join('\n'), function (err, file) {
console.error(report(err || file));
console.log(String(file));
});
stderr(4) yields:
no issues found
stdout(4) yields:
<h2>Hello, world!</h2>
<pre><code class="hljs language-javascript"><span class="hljs-meta">"use strict"</span>
<span class="hljs-keyword">var</span> name = <span class="hljs-string">"World"</span>;
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Hello, "</span> + name + <span class="hljs-string">"!"</span>);
</code></pre>
origin.use(remark2rehype[, destination][, options])
Either bridge or mutate from remark (MDAST) to rehype (HAST).
destination
If given (Unified
), runs the destination processor
with the new HAST tree, then, after running discards that tree and
continues on running the origin processor with the original tree
(bridge-mode). Otherwise, passes the tree to further
plug-ins (mutate-mode).
options
options
are passed through to mdast-util-to-hast
, if given.
FAQs
remark plugin that turns markdown into HTML to support rehype
The npm package remark-rehype receives a total of 3,602,572 weekly downloads. As such, remark-rehype popularity was classified as popular.
We found that remark-rehype 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.