Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including metalsmith-prism with all npm packages installed. Try it out:

var metalsmithPrism = require("metalsmith-prism")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

metalsmith-prism v3.1.1

Syntax highlighting for Metalsmith HTML templates using Prism.js

metalsmith-prism

Syntax highlighting for Metalsmith HTML templates using Prism.js

License NPM Dependency Status Linux Passing Windows Passing

Requirements

  • Node >= 4.x.x
  • NPM >= v3.x.x
  • Metalsmith >= v2.x.x

Quickstart

  • Install metalsmith-prism
  npm install metalsmith-prism --save-dev
  • Add language definition to code block
<code class="language-css">p { color: red }</code>
  • Add metalsmith-prism plugin to metalsmith
const metalsmith = require('metalsmith');
const metalsmithPrism = require('metalsmith-prism');

metalsmith(__dirname)
  .use(metalsmithPrism())
  .build();
const metalsmith = require('metalsmith');
const markdown = require('metalsmith-markdown');
const metalsmithPrism = require('metalsmith-prism');

metalsmith(__dirname)
  // Custom langPrefix option needed as markdown uses 'lang-' by default:
  .use(markdown( { langPrefix: 'language-' } ))
  .use(metalsmithPrism())
  .build();

Language support

Supports all programming languages that have a corresponding Prism.js component file. Component files are found in the Prism.js components directory.

Options

decode (optional)

  • Always decode the html entities when processing language of type markup
Metalsmith(__dirname)
  .use(metalsmithPrism({
    decode: true
  }))

lineNumbers (optional)

  • Appends class line-numbers to parent <pre> tag if present
Metalsmith(__dirname)
  .use(metalsmithPrism({
    lineNumbers: true
  }))

preLoad (optional)

  • Pre-loads language component(s), such that each language component registers itself in the order given in the input array
  • Useful for loading syntax that extends other language components that are not automatically registered by Prism
Metalsmith(__dirname)
  .use(metalsmithPrism({
    preLoad: ["java", "scala"]
  }))

Authors

Robert McGuinness

Disclaimer

Open source software components distributed or made available in the Availity Materials are licensed to Company under the terms of the applicable open source license agreements, which may be found in text files included in the Availity Materials.

Copyright and license

Code and documentation copyright 2017 Availity, LLC. Code released under the MIT license.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free