mirror of https://github.com/requarks/wiki
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.
27 lines
641 B
27 lines
641 B
2 years ago
|
const asciidoctor = require('asciidoctor')()
|
||
|
const cheerio = require('cheerio')
|
||
|
|
||
|
module.exports = {
|
||
|
async render() {
|
||
|
const html = asciidoctor.convert(this.input, {
|
||
|
standalone: false,
|
||
|
safe: this.config.safeMode,
|
||
|
attributes: {
|
||
|
showtitle: true,
|
||
|
icons: 'font'
|
||
|
}
|
||
|
})
|
||
|
|
||
|
const $ = cheerio.load(html, {
|
||
|
decodeEntities: true
|
||
|
})
|
||
|
|
||
|
$('pre.highlight > code.language-diagram').each((i, elm) => {
|
||
|
const diagramContent = Buffer.from($(elm).html(), 'base64').toString()
|
||
|
$(elm).parent().replaceWith(`<pre class="diagram">${diagramContent}</div>`)
|
||
|
})
|
||
|
|
||
|
return $.html()
|
||
|
}
|
||
|
}
|