Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rehype-prism

Package Overview
Dependencies
Maintainers
0
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rehype-prism - npm Package Compare versions

Comparing version 2.3.2 to 2.3.3

eslint.config.cjs

7

CHANGELOG.md

@@ -6,2 +6,9 @@ # Change Log

<a name="0.1.1"></a>
## [2.3.3](https://github.com/Val-istar-Guo/rehype-prism/compare/v2.3.2...v2.3.3) (2024-10-29)
### Performance Improvements
* upgrade dependencies ([733abe2](https://github.com/Val-istar-Guo/rehype-prism/commit/733abe2bffd23ea0c1d569b25010f8901a8cab3b))
## [2.3.2](https://github.com/Val-istar-Guo/rehype-prism/compare/v2.3.1...v2.3.2) (2023-11-09)

@@ -8,0 +15,0 @@

51

package.json
{
"name": "rehype-prism",
"version": "2.3.2",
"version": "2.3.3",
"description": "The unified plugin used to highlight code block in html with Prism",

@@ -38,37 +38,34 @@ "keywords": [

"dependencies": {
"hastscript": "^7 || ^8",
"prismjs": "^1.26",
"rehype-parse": "^7 || ^ 8 || ^9",
"unist-util-is": "^4 || ^5 || ^6",
"unist-util-select": "^4.0.2 || ^5",
"hastscript": "^8.0.0",
"prismjs": "^1.29.0",
"rehype-parse": "^9.0.1",
"unist-util-is": "^6.0.0",
"unist-util-select": "^5.1.0",
"unist-util-visit": "^5.0.0"
},
"devDependencies": {
"@buka/eslint-config": "^1.5.0",
"@commitlint/cli": "^18.2.0",
"@commitlint/config-conventional": "^18.1.0",
"@buka/eslint-config": "^2.1.2",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@jest/globals": "^29.7.0",
"@rushstack/eslint-patch": "^1.5.1",
"@types/hast": "*",
"@types/mdast": "*",
"@types/node": ">12",
"@types/prismjs": "^1.26.2",
"@types/unist": "*",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"eslint": "^8.53.0",
"husky": "^8.0.3",
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.4",
"@types/node": "^22.8.2",
"@types/prismjs": "^1.26.5",
"@types/unist": "^3.0.3",
"eslint": "^9.13.0",
"husky": "^9.1.6",
"is-ci": "^3.0.1",
"jest": "^29.7.0",
"jest-mock": "^29.7.0",
"rehype-stringify": "^10.0.0",
"rehype-stringify": "^10.0.1",
"remark-parse": "^11.0.0",
"remark-rehype": "^11.0.0",
"remark-rehype": "^11.1.1",
"standard-version": "^9.5.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"ts-patch": "^3.0.2",
"typescript": "^5.2.2",
"typescript-transform-paths": "^3.4.6",
"unified": "^11.0.4"
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"ts-patch": "^3.2.1",
"typescript": "5.4.5",
"typescript-transform-paths": "^3.5.1",
"unified": "^11.0.5"
},

@@ -75,0 +72,0 @@ "peerDependencies": {

@@ -9,3 +9,2 @@ <!-- title -->

[![version](https://img.shields.io/npm/v/rehype-prism.svg?logo=npm&style=for-the-badge)](https://www.npmjs.com/package/rehype-prism)

@@ -17,3 +16,2 @@ [![downloads](https://img.shields.io/npm/dm/rehype-prism.svg?logo=npm&style=for-the-badge)](https://www.npmjs.com/package/rehype-prism)

<!-- description -->

@@ -29,21 +27,21 @@

This package is ESM only: Node 12+ and [unified 10](https://www.npmjs.com/package/unified) is needed to use it and it must be imported instead of required.
This package is ESM only. [unified >= 10](https://www.npmjs.com/package/unified) is needed to use it. If running on the server side, NodeJS needs to be greater than 12
```typescript
import { unified } from 'unified'
import rehype from 'rehype'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import rehypePrism from 'rehype-prism'
import rehypeStringify from 'rehype-stringify'
import { unified } from "unified";
import rehype from "rehype";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import rehypePrism from "rehype-prism";
import rehypeStringify from "rehype-stringify";
// you have to load css manual
import 'prismjs/themes/prism-coy.css'
import 'prismjs/plugins/line-numbers/prism-line-numbers.css'
import "prismjs/themes/prism-coy.css";
import "prismjs/plugins/line-numbers/prism-line-numbers.css";
// load languages manual
// import 'prismjs/components/prism-{language}'
import 'prismjs/components/prism-go'
import 'prismjs/components/prism-java'
import 'prismjs/components/prism-python'
import "prismjs/components/prism-go";
import "prismjs/components/prism-java";
import "prismjs/components/prism-python";

@@ -55,12 +53,9 @@ // parse markdown to html

// it should be after rehype
.use(rehypePrism, { plugins: ['line-numbers'] })
.use(rehypePrism, { plugins: ["line-numbers"] })
.use(rehypeStringify)
.parse(/* markdown string */)
.parse(/* markdown string */);
// .processSync(/* markdown string */)
// parse code block in html string
rehype()
.use(rehypePrism)
.use(rehypeStringify)
.parse(/* html string */)
rehype().use(rehypePrism).use(rehypeStringify).parse(/* html string */);
// .processSync(/* html string */)

@@ -92,3 +87,3 @@ ```

| Plugin Name |
|:------------------|
| :---------------- |
| line-numbers |

@@ -104,4 +99,5 @@ | toolbar |

- Use [babel-plugin-prismjs](https://www.npmjs.com/package/babel-plugin-prismjs).(Recommend)
- Use [babel-plugin-prismjs](https://www.npmjs.com/package/babel-plugin-prismjs).
- Use `loadLanguages()` provided by `prismjs`.(don't use `loadLanguages()` with Webpack or another bundler)
- Import language manual. e.g. `import 'prismjs/components/prism-yaml.js'`

@@ -114,2 +110,9 @@ ## Load Themes

## See More
[shiki](https://github.com/shikijs/shiki) is another code highlight tools that support [unified](https://www.npmjs.com/package/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.
<!-- usage -->

@@ -116,0 +119,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc