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:
Boris
2022-12-24 04:19:16 +03:00
committed by GitHub
parent eadefb8827
commit 54dbf9ad00
15 changed files with 1039 additions and 192 deletions

View File

@@ -0,0 +1,20 @@
key: asciidocCore
title: Core
description: Basic Asciidoc Parser
author: dzruyk (Based on asciidoctor.js renderer)
input: asciidoc
output: html
icon: mdi-sitemap
enabledDefault: true
props:
safeMode:
type: String
default: server
title: Safe Mode
hint: Sets the safe mode to use when parsing content to HTML.
order: 1
enum:
- unsafe
- safe
- server
- secure

View 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()
}
}