src/modules/markdown.js (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | "use strict";
const highlight = require("highlight.js");
const Markdown = require("markdown-it");
const markdownOptions = {
html: true,
typographer: true,
highlight: function(str, lang) {
if (lang && highlight.getLanguage(lang)) {
try {
return `
${highlight.highlight(lang, str).value}`;
} catch (error) {
console.error("highlighting failed", error);
}
}
return "";
}
};
const markdown = new Markdown(markdownOptions);
module.exports = markdown.render.bind(markdown);
|