blob: a1ed8c3928caf838bb91e2a38741dca27147b1ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
const { Marked } = require('marked');
const { markedHighlight } = require('marked-highlight');
const hljs = require('highlight.js');
const { renderer, hooks } = require('./marked-renderer.js');
module.exports = function loader(source) {
const marker = new Marked(
{ renderer, hooks },
markedHighlight({
highlight(code, lang) {
const language = hljs.getLanguage(lang) ? lang : 'plaintext';
return hljs.highlight(code, { language }).value;
}
}),
);
return marker.parse(source);
}
|