Package Exports
- rehype-prism
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rehype-prism) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
rehype-prism
Install
npm i rehype-prism
Usage
import unified from 'unified'
import markdown from 'remark-parse'
import remark2rehype from 'remark-rehype'
import highlightCode from 'rehype-prism'
import html from 'rehype-stringify'
unified()
.use(markdown)
.use(remark2rehype)
// it should be after rehype
.use(highlightCode)
.use(html)
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>
Load More Languages
- Use babel-plugin-prismjs.(Recommend)
- Use
loadLanguages()
provided byprismjs
.(don't useloadLanguages()
with Webpack or another bundler)
Load Themes
- If you use babel-plugin-prismjs.
import 'prismjs'
will auto load the theme setted in babel-plugin-prismjs config. - Import theme css manual. e.g.
import 'prismjs/themes/prism-coy.css'