Syntax highlighting for Metalsmith HTML templates using Prism.js
- Install metalsmith-prism with npm
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
var metalsmith = require('metalsmith');
var metalsmithPrism = require('metalsmith-prism');
metalsmith(__dirname)
.use(metalsmithPrism())
.build();
JSON syntax highlighting is enhanced using the following syntax definition
Prism.languages.json = {
'keys': /".+"(?=:)/g,
'boolean': /\b(true|false)/g,
'punctuation': /({|}|:|\[|\]|,)/g,
'keyword': /\b(null)\b/g
}
Robert McGuinness
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.
Code and documentation copyright 2015 Availity, LLC. Code released under the MIT license.