UNPKG

3.05 kBMarkdownView Raw
1# metalsmith-prism
2
3> Syntax highlighting for [Metalsmith](http://www.metalsmith.io/) HTML templates using [Prism.js](http://prismjs.com/)
4
5[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square&label=license)](http://opensource.org/licenses/MIT)
6[![NPM](http://img.shields.io/npm/v/metalsmith-prism.svg?style=flat-square&label=npm)](https://npmjs.org/package/metalsmith-prism)
7[![Dependency Status](https://img.shields.io/david/Availity/metalsmith-prism.svg?style=flat-square)](https://david-dm.org/Availity/metalsmith-prism)
8[![Linux Passing](https://img.shields.io/travis/Availity/metalsmith-prism.svg?style=flat-square&label=linux)](https://travis-ci.org/Availity/metalsmith-prism)
9[![Windows Passing](https://img.shields.io/appveyor/ci/robmcguinness/metalsmith-prism.svg?style=flat-square&label=windows)](https://ci.appveyor.com/project/robmcguinness/metalsmith-prism)
10
11## Upgrading to version 3
12
13+ Node dependency to `>=4.x.x`
14+ Metalsmith to `=>v2.x.x`
15
16## Quickstart
17
18+ Install **metalsmith-prism**
19
20>
21```bash
22 npm install metalsmith-prism --save-dev
23```
24
25+ Add language definition to code block
26
27>
28```html
29<code class="language-css">p { color: red }</code>
30```
31
32+ Add `metalsmith-prism` plugin to metalsmith
33
34>
35```js
36var metalsmith = require('metalsmith');
37var metalsmithPrism = require('metalsmith-prism');
38metalsmith(__dirname)
39 .use(metalsmithPrism())
40 .build();
41```
42
43+ **_OPTIONAL_** To use with Markdown code blocks rendered by [metalsmith-markdown](https://github.com/segmentio/metalsmith-markdown)
44
45>
46```js
47var metalsmith = require('metalsmith');
48var markdown = require('metalsmith-markdown');
49var metalsmithPrism = require('metalsmith-prism');
50metalsmith(__dirname)
51 // Custom langPrefix option needed as markdown uses 'lang-' by default:
52 .use(markdown( { langPrefix: 'language-' } ))
53 .use(metalsmithPrism())
54 .build();
55```
56
57## Language support
58
59Supports all programming languages that have a corresponding Prism.js component file. Component files are found in the [Prism.js `components` directory](https://github.com/PrismJS/prism/tree/master/components).
60
61### Options
62
63#### decode (optional)
64
65- Always decode the html entities when processing language of type `markup`
66
67```javascript
68Metalsmith(__dirname)
69 .use(metalsmithPrism({
70 decode: true
71 }))
72```
73
74#### lineNumbers (optional)
75
76- Appends class `line-numbers` to parent `<pre>` tag if present
77
78```javascript
79Metalsmith(__dirname)
80 .use(metalsmithPrism({
81 lineNumbers: true
82 }))
83```
84
85## Authors
86
87**Robert McGuinness**
88+ [rob.mcguinness@availity.com](rob.mcguinness@availity.com)
89
90## Disclaimer
91
92Open 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.
93
94## Copyright and license
95
96Code and documentation copyright 2016 Availity, LLC. Code released under [the MIT license](https://github.com/Availity/metalsmith-prism/blob/master/LICENSE).
97
98
99