aboutsummaryrefslogtreecommitdiff
path: root/loaders
diff options
context:
space:
mode:
Diffstat (limited to 'loaders')
-rw-r--r--loaders/marked.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/loaders/marked.js b/loaders/marked.js
new file mode 100644
index 0000000..f3c8fcb
--- /dev/null
+++ b/loaders/marked.js
@@ -0,0 +1,16 @@
+const { Marked } = require('marked');
+const { markedHighlight } = require('marked-highlight');
+const hljs = require('highlight.js');
+
+module.exports = function loader(source) {
+ const marker = new Marked(
+ markedHighlight({
+ highlight(code, lang) {
+ const language = hljs.getLanguage(lang) ? lang : 'plaintext';
+ return hljs.highlight(code, { language }).value;
+ }
+ })
+ );
+
+ return marker.parse(source);
+}