forked from deepsweet/markdown-highlight-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (28 loc) · 776 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
var loaderUtils = require('loader-utils');
var marked = require('marked');
var highlight = require('highlight.js');
module.exports = function(source) {
var query = loaderUtils.parseQuery(this.query);
var options = {
renderer: new marked.Renderer(),
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: true,
smartLists: true,
smartypants: false,
langPrefix: 'hljs ',
highlight: function(code) {
return highlight.highlightAuto(code).value;
}
};
if (this.cacheable) {
this.cacheable();
}
Object.keys(query).forEach(function(key) {
options[key] = query[key];
});
return marked(source, options);
};