![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
remark-prism
Advanced tools
Syntax highlighter for markdown code blocks using Prism - with support for certain plugins. This allows syntax highlighting without running any client-side code - other than CSS.
λ yarn add remark-prism
Input:
const src = `
\`\`\`javascript
console.log('Hello World');
\`\`\`
`;
Using remark (mdast):
require('unified')()
.use(require('remark-parse'))
.use(require('remark-stringify'))
.use(require('remark-prism'), {
/* options */
})
.use(require('remark-html'))
.process(file, (err, file) => console.log(String(file)));
Using rehype (hast):
require('unified')()
.use(require('remark-parse'))
.use(require('remark-prism'), {
/* options */
})
.use(require('remark-rehype'))
.use(require('rehype-format'))
.use(require('rehype-stringify'))
.process(file, (err, file) => console.log(String(file)));
Using mdx:
console.log(
await require('@mdx-js/mdx')(src, {
commonmark: true,
gfm: true,
remarkPlugins: [
[
require('remark-prism'),
{
/* options */
},
],
],
}),
);
Output:
<div class="remark-highlight">
<pre class="language-javascript">
<code>
<span class="token console class-name">console</span>
<span class="token punctuation">.</span>
<span class="token method function property-access">log</span>
<span class="token punctuation">(</span>
<span class="token string">'Hello World'</span>
<span class="token punctuation">)</span>
<span class="token punctuation">;</span>
</code>
</pre>
</div>
Take a look at our fixtures and it's outputs to see more examples.
transformInlineCode
Add relevant class names to inline code snippets. For example when you use single backtick code examples.
use(require('remark-prism'), {
transformInlineCode: true,
});
It supports some Prism plugins:
use(require('remark-prism'), {
plugins: [
'autolinker',
'command-line',
'data-uri-highlight',
'diff-highlight',
'inline-color',
'keep-markup',
'line-numbers',
'show-invisibles',
'treeview',
],
});
Don't forget to include the appropriate css in your stylesheets. Refer to the documentation of each plugin.
\`\`\`diff-javascript[class="line-numbers"][class="diff-highlight"]
<pre class="language-diff-javascript diff-highlight line-numbers">...</pre>
BSD-3-Clause
1.3.5 (2021-03-30)
FAQs
Syntax highlighter for markdown code blocks - with support for plugins
The npm package remark-prism receives a total of 4,135 weekly downloads. As such, remark-prism popularity was classified as popular.
We found that remark-prism demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.