0.0.2 • Published 9 years ago
magu-plugin-hljs v0.0.2
magu-plugin-toc
Magu plugin that highlight code block use the Highlight.js
Install
yarn add magu-plugin-hljs
npm install magu-plugin-hljsUsage
magu({}, [hljs({
// Below is the default value
selector: 'pre > code[class*="lang-"]',
selectorMatcher: /lang-([\w_-]+)/
})])
.process(`${__dirname}/path/to/file.md`)
.then(result => console.log(result.html));Register custom language
Use require('magu-plugin-hljs').registerLanguage.
It is the same as registerLanguage of Highlight.js.
Please refer to highlightjs.readthedocs.io/en/latest/api.html#registerlanguage-name-language.
Options
selector(default:'pre > code[class*="lang-"]')selectorMatcher(default:/lang-([\w_-]+)/)
Example
The following . is simply to make it uninterrupted there.
```js
console.log('aiueo');
```.
```css
body {
color: orange;
}
```.result like this.
<pre><code class="lang-js">console.log(&#39;aiueo&#39;);
</code></pre>
<pre><code class="lang-css"><span class="hljs-selector-tag">body</span> {
<span class="hljs-attribute">color</span>: orange;
}
</code></pre>License
The MIT License (MIT) Copyright (c) 2016 nju33 nju33.ki@gmail.com