Gitbook Plugin for Prism

NPM

Before

Gitbook Plugin for Prism - 图2

After

Gitbook Plugin for Prism - 图3

Usage

Add the plugin to your book.json, and disable default GitBook code highlighting:

  1. {
  2. "plugins": ["prism", "-highlight"]
  3. }

Options

css

Override default styles. All css files must reside in the same folder.

  1. "pluginsConfig": {
  2. "prism": {
  3. "css": [
  4. "prismjs/themes/prism-solarizedlight.css"
  5. ]
  6. }
  7. }

lang

Support non-standard syntax prefixes by aliasing existing prefixes.

  1. "pluginsConfig": {
  2. "prism": {
  3. "lang": {
  4. "flow": "typescript"
  5. }
  6. }
  7. }

ignore

Due to other plugins using code block notion to denote other functionality, you can ignore certain langs

  1. "pluginsConfig": {
  2. "prism": {
  3. "ignore": [
  4. "mermaid",
  5. "eval-js"
  6. ]
  7. }
  8. }

Prism Themes

https://github.com/PrismJS/prism

Okaidia prismjs/themes/prism-okaidia.css

Okaidia

Solarized Light prismjs/themes/prism-solarizedlight.css

Solarized Light

Tomorrow prismjs/themes/prism-tomorrow.css

Tomorrow

Dark prismjs/themes/prism-dark.css

Dark

Coy prismjs/themes/prism-coy.css

Coy

Atelierbram Themes

https://github.com/atelierbram/syntax-highlighting

Base16 Ocean Dark syntax-highlighting/assets/css/prism/prism-base16-ocean.dark.css

Base16 Ocean Dark

Google Light syntax-highlighting/assets/css/prism/prism-base16-google.light.css

Google Light

Xonokai syntax-highlighting/assets/css/prism/prism-xonokai.css

Google Light

Credits

Originally based on https://github.com/spricity/google_code_prettify.

License

Apache 2