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

rehype-prism

Package Overview
Dependencies
Maintainers
1
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 0.1.1 to 1.0.0

.editorconfig

16

CHANGELOG.md

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

<a name="0.1.1"></a>
## [1.0.0](https://www.github.com/Val-istar-Guo/rehype-prism/compare/v0.1.1...v1.0.0) (2021-07-17)
### ⚠ BREAKING CHANGES
* This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required. And remove preLangClass option.
### Features
* prismjs plugins support ([40ba951](https://www.github.com/Val-istar-Guo/rehype-prism/commit/40ba951e8ab5206dffcb28b65f119df14ee5c58d)), closes [#3](https://www.github.com/Val-istar-Guo/rehype-prism/issues/3)
### Code Refactoring
* rewrite by typescript and esm only ([7ea69f0](https://www.github.com/Val-istar-Guo/rehype-prism/commit/7ea69f0ef984b3c569ef9cf5356f0324a91b3c0a))
## [0.1.1](https://github.com/Val-istar-Guo/rehype-prism/compare/v0.1.0...v0.1.1) (2019-03-05)

@@ -8,0 +24,0 @@

110

package.json
{
"name": "rehype-prism",
"main": "dist/bundle.js",
"module": "src/index.js",
"type": "module",
"main": "lib/index.js",
"scripts": {

@@ -9,5 +9,5 @@ "test": "ava",

"upgrade": "mili upgrade",
"clean": "rm -rf ./dist/*",
"build": "npm run clean & rollup -c",
"prepublishOnly": "npm test; npm run build",
"clean": "rm -rf ./lib/*",
"build": "ttsc && npm run copyfile",
"prepublishOnly": "npm run build",
"ca": "git add -A && git-cz -av",

@@ -18,10 +18,18 @@ "commit": "git-cz",

"release:first": "standard-version --first-release",
"postpublish": "git push",
"report": "nyc npm run test",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls"
"report": "nyc --reporter=html --reporter=text-summary --skip-full ava",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
"lint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\" --fix",
"prepare": "is-ci || husky install",
"ci": "git-cz",
"test:debug": "ava --verbose",
"test:update": "ava -u",
"prebuild": "npm run clean",
"prewatch": "npm run copyfile",
"watch": "NODE_ENV=development ttsc -w",
"copyfile": "copyfiles -e \"@(build|es|lib|node_modules|tests|doc)/**/*.!(ts)\" -e \"@(README.md|CHANGELOG.md|ava.config.js|backers.md)\" \"**/*.!(ts)\" lib"
},
"description": "The unified plugin used to highlight code block in html with Prism",
"version": "0.1.1",
"version": "1.0.0",
"directories": {
"test": "test"
"test": "tests"
},

@@ -51,52 +59,44 @@ "repository": {

"homepage": "https://github.com/Val-istar-Guo/rehype-prism#readme",
"ava": {
"files": [
"test/**/*.js",
"!**/macros.js",
"!**/*.macros.js"
],
"sources": [
"src/**/*.js"
],
"failFast": true,
"require": [
"babel-register",
"babel-polyfill"
]
},
"devDependencies": {
"@commitlint/cli": "^7.2.0",
"@commitlint/config-conventional": "^7.1.2",
"ava": "^1.0.0-beta.4",
"babel-core": "^6.26.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-register": "^6.26.0",
"commitizen": "^3.0.2",
"coveralls": "^3.0.2",
"cz-conventional-changelog": "^2.1.0",
"husky": "^1.0.1",
"nyc": "^13.1.0",
"rehype-stringify": "^5.0.0",
"remark-parse": "^6.0.3",
"remark-rehype": "^4.0.0",
"rollup": "^0.58.0",
"rollup-plugin-babel": "^3.0.3",
"rollup-plugin-commonjs": "^9.1.0",
"rollup-plugin-json": "^3.0.0",
"rollup-plugin-node-resolve": "^3.3.0",
"standard-version": "^4.4.0",
"unified": "^7.1.0"
"@ava/babel": "^2.0.0",
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@typescript-eslint/eslint-plugin": "^4.15.2",
"@typescript-eslint/parser": "^4.15.2",
"ava": "^3.10.1",
"commitizen": "^4.2.4",
"copyfiles": "^2.4.1",
"coveralls": "^3.1.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.20.0",
"husky": "^5.2.0",
"is-ci": "^3.0.0",
"lint-staged": "^11.0.0",
"mili": "^4.7.4",
"nyc": "^15.1.0",
"rehype-stringify": "^8.0.0",
"remark-parse": "^9.0.0",
"remark-rehype": "^8.1.0",
"sinon": "^10.0.0",
"standard-version": "^9.3.0",
"ts-node": "^9.1.1",
"ttypescript": "^1.5.12",
"typescript": "^4.2.2",
"typescript-transform-paths": "^2.2.3",
"unified": "9.2.1"
},
"dependencies": {
"prismjs": "^1.15.0",
"rehype-parse": "^6.0.0",
"unist-util-modify-children": "^1.1.3",
"unist-util-visit": "^1.4.0"
"@types/node": "^14.14.31",
"@types/prismjs": "^1.16.6",
"prismjs": "^1.24.1",
"rehype-parse": "^7.0.1",
"unist-util-is": "^4.1.0",
"unist-util-select": "^4.0.0",
"unist-util-visit": "^3.1.0"
},
"peerDependencies": {
"unified": "^7.0.2"
}
"unified": "^9.2.1"
},
"types": "lib/index.d.ts"
}

@@ -10,23 +10,25 @@ # rehype-prism

<!-- custom -->
<!-- description -->
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
<!-- description -->
## Usage
## Install
<!-- usage -->
This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.
```bash
npm i rehype-prism
```
## Usage
```javascript
```typescript
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'
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'
// parse markdown to html

@@ -37,3 +39,3 @@ unified()

// it should be after rehype
.use(highlightCode, { preLangClass: false })
.use(rehypePrism, { plugins: ['line-numbers'] })
.use(html)

@@ -44,3 +46,3 @@ .parse(/* markstring string */)

rehyper()
.use(highlightCode)
.use(rehypePrism)
.use(html)

@@ -50,4 +52,8 @@ .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:
## Server Side Render
`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 }`

@@ -58,10 +64,8 @@ * use the attribute `data-manual` on the `<script>` element you used for prism.

## Options
> Some plugins will not work(e.g. `line-number`). Because it's only work in browser.
- **preLangClass(default: true)**: Whether to copy the `language-` class to the `<pre>` tag.
## Load Plugins
Some css style will be set to the `<pre class="language-xxx">`, if you use the official theme.
The names to use can be found [here](https://github.com/PrismJS/prism/tree/master/plugins).
## Load More Languages

@@ -78,2 +82,10 @@

<!-- custom -->
<!-- usage -->
<!-- addition --><!-- addition -->
## Contributing & Development
If there is any doubt, it is very welcome to discuss the issue together.
Please read [Contributor Covenant Code of Conduct](.github/CODE_OF_CONDUCT.md) and [CONTRIBUTING](.github/CONTRIBUTING.md).

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