mAAdhaTTah / babel-plugin-prismjs

A babel plugin to use PrismJS with standard bundlers.
157 stars 9 forks source link
babel babel-plugin browserify prismjs rollup syntax-highlighting webpack

babel-plugin-prismjs Build Status

A babel plugin to use PrismJS with standard bundlers.

How to Use

This plugin allows you to treat PrismJS as a standard module and configure what languages, plugins, & themes you want to bundle with Prism.

In your code, import prismjs:

import Prism from 'prismjs';

// if you are intending to use Prism functions manually, you will need to set:
Prism.manual = true;

Prism.highlightAll();

The exported Prism object will be the fully-configured Prism instance.

Limitations

Configuring the plugin

In your .babelrc, register the plugin and configure its dependencies:

{
  "plugins": [
    ["prismjs", {
        "languages": ["javascript", "css", "markup"],
        "plugins": ["line-numbers"],
        "theme": "twilight",
        "css": true
    }]
  ]
}

Each key are used as follows: