20 lines
491 B
JavaScript
20 lines
491 B
JavaScript
import markdown from 'remark-parse'
|
|
import remark2rehype from 'remark-rehype'
|
|
import remarkBreaks from 'remark-breaks'
|
|
import unified from 'unified'
|
|
import hast2html from '@starptech/prettyhtml-hast-to-html'
|
|
|
|
function stringify(options = {}) {
|
|
this.Compiler = (tree) => hast2html(tree, options)
|
|
}
|
|
|
|
const compiler = unified()
|
|
.use(markdown)
|
|
.use(remark2rehype)
|
|
.use(remarkBreaks)
|
|
.use(stringify)
|
|
|
|
export default function (input) {
|
|
return compiler.processSync(input)
|
|
}
|