rehype-prism
Advanced tools
Comparing version 0.1.1 to 1.0.0
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
86
Yes
15351
8
27
16
69
1
1
+ Added@types/node@^14.14.31
+ Added@types/prismjs@^1.16.6
+ Addedunist-util-is@^4.1.0
+ Addedunist-util-select@^4.0.0
+ Added@types/hast@2.3.10(transitive)
+ Added@types/node@14.18.63(transitive)
+ Added@types/parse5@5.0.3(transitive)
+ Added@types/prismjs@1.26.5(transitive)
+ Addedboolbase@1.0.0(transitive)
+ Addedcss-selector-parser@1.4.1(transitive)
+ Addedhast-util-from-parse5@6.0.1(transitive)
+ Addedhastscript@6.0.0(transitive)
+ Addedis-plain-obj@2.1.0(transitive)
+ Addednth-check@2.1.1(transitive)
+ Addedparse5@6.0.1(transitive)
+ Addedrehype-parse@7.0.1(transitive)
+ Addedunified@9.2.2(transitive)
+ Addedunist-util-is@4.1.05.2.1(transitive)
+ Addedunist-util-select@4.0.3(transitive)
+ Addedunist-util-stringify-position@2.0.3(transitive)
+ Addedunist-util-visit@3.1.0(transitive)
+ Addedunist-util-visit-parents@4.1.1(transitive)
+ Addedvfile@4.2.1(transitive)
+ Addedvfile-location@3.2.0(transitive)
+ Addedvfile-message@2.0.4(transitive)
+ Addedzwitch@2.0.4(transitive)
- Removedunist-util-modify-children@^1.1.3
- Removed@types/node@22.9.1(transitive)
- Removed@types/unist@3.0.3(transitive)
- Removed@types/vfile@3.0.2(transitive)
- Removed@types/vfile-message@2.0.0(transitive)
- Removedarray-iterate@1.1.4(transitive)
- Removedccount@1.1.0(transitive)
- Removedhast-util-from-parse5@5.0.3(transitive)
- Removedhastscript@5.1.2(transitive)
- Removedis-plain-obj@1.1.0(transitive)
- Removedparse5@5.1.1(transitive)
- Removedrehype-parse@6.0.2(transitive)
- Removedreplace-ext@1.0.0(transitive)
- Removedundici-types@6.19.8(transitive)
- Removedunified@7.1.0(transitive)
- Removedunist-util-is@3.0.0(transitive)
- Removedunist-util-modify-children@1.1.6(transitive)
- Removedunist-util-stringify-position@1.1.24.0.0(transitive)
- Removedunist-util-visit@1.4.1(transitive)
- Removedunist-util-visit-parents@2.1.2(transitive)
- Removedvfile@3.0.1(transitive)
- Removedvfile-message@1.1.14.0.2(transitive)
- Removedx-is-string@0.1.0(transitive)
Updatedprismjs@^1.24.1
Updatedrehype-parse@^7.0.1
Updatedunist-util-visit@^3.1.0