You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Hydro/hydro/lib/markdown.js

29 lines
812 B
JavaScript

5 years ago
const MarkdownIt = require('markdown-it');
const katex = require('markdown-it-katex');
const Prism = require('prismjs');
5 years ago
require('prismjs/components/index');
class Markdown extends MarkdownIt {
5 years ago
constructor(safe) {
super({
linkify: true,
5 years ago
highlight(str, lang) {
if (lang && Prism.languages[lang]) {
try {
return Prism.highlight(str, Prism.languages[lang], lang);
} catch (__) { } // eslint-disable-line no-empty
5 years ago
}
return '';
5 years ago
},
5 years ago
html: !safe,
});
this.linkify.tlds('.py', false);
this.use(katex);
}
}
4 years ago
global.Hydro.lib.markdown = module.exports = {
5 years ago
unsafe: new Markdown(false),
safe: new Markdown(true),
};