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.
rehype-prism
Advanced tools
The unified plugin used to highlight code block in html with Prism.
And you have the ability to control whether to copy the language-
class to <pre>
tag
npm i rehype-prism
import unified from 'unified'
import rehyper from 'rehyper'
import markdown from 'remark-parse'
import remark2rehype from 'remark-rehype'
import highlightCode from 'rehype-prism'
import html from 'rehype-stringify'
// parse markdown to html
unified()
.use(markdown)
.use(remark2rehype)
// it should be after rehype
.use(highlightCode, { preLangClass: false })
.use(html)
.parse(/* markstring string */)
// parse code block in html string
rehyper()
.use(highlightCode)
.use(html)
.parse(/* html string */)
Must disabled prism autoHighlight before import 'rehype-prism'
, if you use the plugin in browser. there are two way to do this:
set the window.Prism = { manual: true }
use the attribute data-manual
on the <script>
element you used for prism.
<script src="prism.js" data-manual></script>
preLangClass(default: true): Whether to copy the language-
class to the <pre>
tag.
Some css style will be set to the <pre class="language-xxx">
, if you use the official theme.
loadLanguages()
provided by prismjs
.(don't use loadLanguages()
with Webpack or another bundler)import 'prismjs'
will auto load the theme setted in babel-plugin-prismjs config.import 'prismjs/themes/prism-coy.css'
FAQs
The unified plugin used to highlight code block in html with Prism
The npm package rehype-prism receives a total of 3,339 weekly downloads. As such, rehype-prism popularity was classified as popular.
We found that rehype-prism demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.