You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
735 B
39 lines
735 B
const MarkdownIt = require("markdown-it")
|
|
const md = new MarkdownIt({
|
|
html: true,
|
|
linkify: true,
|
|
typographer: false,
|
|
langPrefix: "language-",
|
|
})
|
|
md.use(require("markdown-it-container"), "green")
|
|
md.use(require("markdown-it-container"), "orange")
|
|
md.use(require("markdown-it-container"), "blue")
|
|
md.use(require("./plugins/wikilink"))
|
|
|
|
const renderer = md.renderer
|
|
|
|
module.exports = class {
|
|
onCreate(input) {
|
|
this.state = {
|
|
render: () => {},
|
|
}
|
|
|
|
this.render(input.source || "")
|
|
}
|
|
|
|
onInput(input) {
|
|
if (input.source) {
|
|
this.render(input.source)
|
|
}
|
|
}
|
|
|
|
render(source) {
|
|
this.state.render = (out) => {
|
|
if (out.w) {
|
|
out.w(md.render(source))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
renderer.rules
|