Gathering detailed insights and metrics for rehype-prism
Gathering detailed insights and metrics for rehype-prism
Gathering detailed insights and metrics for rehype-prism
Gathering detailed insights and metrics for rehype-prism
rehype-prism-plus
rehype plugin to highlight code blocks in HTML with Prism (via refractor) with line highlighting and line numbers
@mapbox/rehype-prism
rehype plugin to highlight code blocks in HTML with Prism
@types/mapbox__rehype-prism
TypeScript definitions for @mapbox/rehype-prism
rehype-prism-template
rehype plugin to highlight code blocks in HTML with Prism
The unified plugin used to highlight code block in html with Prism
npm install rehype-prism
Typescript
Module System
Node Version
NPM Version
94.6
Supply Chain
100
Quality
76.6
Maintenance
100
Vulnerability
100
License
TypeScript (97.12%)
JavaScript (2.06%)
Shell (0.82%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
13 Stars
74 Commits
1 Forks
1 Watchers
2 Branches
2 Contributors
Updated on Dec 09, 2024
Minified
Minified + Gzipped
Latest Version
2.3.3
Package Id
rehype-prism@2.3.3
Unpacked Size
32.15 kB
Size
12.25 kB
File Count
49
NPM Version
10.7.0
Node Version
18.20.4
Published on
Oct 29, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
24
The unified plugin used to highlight code block in html with Prism.
This package is ESM only. unified >= 10 is needed to use it. If running on the server side, NodeJS needs to be greater than 12
1import { unified } from "unified"; 2import rehype from "rehype"; 3import remarkParse from "remark-parse"; 4import remarkRehype from "remark-rehype"; 5import rehypePrism from "rehype-prism"; 6import rehypeStringify from "rehype-stringify"; 7 8// you have to load css manual 9import "prismjs/themes/prism-coy.css"; 10import "prismjs/plugins/line-numbers/prism-line-numbers.css"; 11 12// load languages manual 13// import 'prismjs/components/prism-{language}' 14import "prismjs/components/prism-go"; 15import "prismjs/components/prism-java"; 16import "prismjs/components/prism-python"; 17 18// parse markdown to html 19unified() 20 .use(remarkParse) 21 .use(remarkRehype) 22 // it should be after rehype 23 .use(rehypePrism, { plugins: ["line-numbers"] }) 24 .use(rehypeStringify) 25 .parse(/* markdown string */); 26// .processSync(/* markdown string */) 27 28// parse code block in html string 29rehype().use(rehypePrism).use(rehypeStringify).parse(/* html string */); 30// .processSync(/* html string */)
PrismJS
will auto highlight all code at pre code
after browser document
loaded.
Disabled prism autoHighlight before import 'rehype-prism'
. 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>
Some plugins will not work. Because it's only work in browser.
The names to use can be found here.
The table list plugins that cannot running on the server side. Therefor it has been re-implemented by rehype-prism.
Plugin Name |
---|
line-numbers |
toolbar |
copy-to-clipboard |
I haven't tested all prism plugins. If there are another plugins not work, submit issue on github.
loadLanguages()
provided by prismjs
.(don't use loadLanguages()
with Webpack or another bundler)import 'prismjs/components/prism-yaml.js'
import 'prismjs'
will auto load the theme setted in babel-plugin-prismjs config.import 'prismjs/themes/prism-coy.css'
shiki is another code highlight tools that support unified. I recommend you try it. It's new, but better suited for modern front-end projects than Prismjs.
This does not mean that I will give up maintaining this library. If you need this library and have any issue, let me know it.
If there is any doubt, it is very welcome to discuss the issue together.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More