Skip to content
This repository has been archived by the owner. It is now read-only.
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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

Notice

The plugin does not automatically apply prism.js styles to the generated markup. Please see https://github.com/Availity/metalsmith-prism/issues/22 for workarounds.

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.

About

Syntax highlighting for Metalsmith HTML templates using Prism.js

Resources

License

You can’t perform that action at this time.