Skip to content

Commit 155087a

Browse files
committed
Added basic asciidoc extension for [SUCCESS] block admonition. Need to fix corner radii not rendering
1 parent 101dd11 commit 155087a

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

client/components/editor/editor-asciidoc.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ import cmFold from './common/cmFold'
163163
// INIT
164164
// ========================================
165165
const asciidoctor = require('asciidoctor')()
166+
const registry = asciidoctor.Extensions.create()
167+
require('../../modules/asciidoc-extended')(registry)
166168
const cheerio = require('cheerio')
167169
168170
// Platform detection
@@ -222,7 +224,8 @@ export default {
222224
attributes: {
223225
showtitle: true,
224226
icons: 'font'
225-
}
227+
},
228+
'extension_registry': registry
226229
})
227230
const $ = cheerio.load(html, {
228231
decodeEntities: true

client/modules/asciidoc-extended.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Asciidoctor API Documentation for HTML5Converter:
2+
// https://www.rubydoc.info/gems/asciidoctor/2.0.23/Asciidoctor/Converter/Html5Converter#convert_admonition-instance_method
3+
4+
module.exports = function (registry) {
5+
// Success Admonition block rendering
6+
// [SUCCESS]
7+
// <paragraphContent>
8+
registry.block(function () {
9+
var self = this
10+
self.named('SUCCESS')
11+
self.onContext('paragraph')
12+
self.process(function (parent, reader) {
13+
var lines = reader.getLines()
14+
return self.createBlock(parent, 'admonition', lines, {name: 'success', textlabel: 'Success'})
15+
})
16+
})
17+
}

server/modules/rendering/asciidoc-core/renderer.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const asciidoctor = require('asciidoctor')()
2+
const registry = asciidoctor.Extensions.create()
3+
require('../../../../client/modules/asciidoc-extended')(registry)
24
const cheerio = require('cheerio')
35

46
module.exports = {
@@ -9,7 +11,8 @@ module.exports = {
911
attributes: {
1012
showtitle: true,
1113
icons: 'font'
12-
}
14+
},
15+
'extension_registry': registry
1316
})
1417

1518
const $ = cheerio.load(html, {

0 commit comments

Comments
 (0)