feat: add asciidoc editor module (#5954)
* feat: add asciidoc editor module * fix storage file extension for asciidoc pages * fix: asciidoc editor + rendering improvements * fix: description list css improvements Co-authored-by: NGPixel <github@ngpixel.com>
This commit is contained in:
26
server/modules/rendering/asciidoc-core/renderer.js
Normal file
26
server/modules/rendering/asciidoc-core/renderer.js
Normal file
@@ -0,0 +1,26 @@
|
||||
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()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user