963b5d46e6
Usage (ranges are space separated): {% highlight js 1,4-6 %} One range Adds `highlight-line-active` to lines 1,4,5,6 {% highlight js 3-4 -1 %} Two ranges (add/remove), remove is N/A Adds `highlight-line-add` to lines 3,4 {% highlight js -1 3-4 %} Two ranges (add/remove), add is N/A Adds `highlight-line-remove` to lines 3,4 {% highlight js 3-4 5,8-10 %} Two ranges, both are used Adds `highlight-line-add` to lines 3-4 Adds `highlight-line-remove` to lines 5,8,9,10
28 lines
689 B
JavaScript
28 lines
689 B
JavaScript
const Prism = require('prismjs');
|
|
const LiquidHighlight = require( "./LiquidHighlight" );
|
|
|
|
module.exports = {
|
|
plain: function(liquidEngine) {
|
|
let highlight = new LiquidHighlight(liquidEngine);
|
|
|
|
highlight.addClassHook(function(language, line) {
|
|
if( language === "dir" ) {
|
|
// has trailing slash
|
|
if( line.match(/\/$/) !== null ) {
|
|
return "highlight-line-isdir";
|
|
}
|
|
}
|
|
});
|
|
|
|
return highlight.getObject();
|
|
},
|
|
prismjs: function(liquidEngine) {
|
|
let highlight = new LiquidHighlight(liquidEngine);
|
|
|
|
highlight.addHook(function(language, htmlStr, lines) {
|
|
return Prism.highlight(htmlStr, Prism.languages[ language ]);
|
|
});
|
|
|
|
return highlight.getObject();
|
|
}
|
|
}; |