|
|
|
@ -13,6 +13,7 @@ module.exports = {
|
|
|
|
const closeChar = closeMarker.charCodeAt(0)
|
|
|
|
const closeChar = closeMarker.charCodeAt(0)
|
|
|
|
const imageFormat = opts.imageFormat || 'svg'
|
|
|
|
const imageFormat = opts.imageFormat || 'svg'
|
|
|
|
const server = opts.server || 'https://plantuml.requarks.io'
|
|
|
|
const server = opts.server || 'https://plantuml.requarks.io'
|
|
|
|
|
|
|
|
const renderSvgAsObject = opts.renderSvgAsObject || false
|
|
|
|
|
|
|
|
|
|
|
|
md.block.ruler.before('fence', 'uml_diagram', (state, startLine, endLine, silent) => {
|
|
|
|
md.block.ruler.before('fence', 'uml_diagram', (state, startLine, endLine, silent) => {
|
|
|
|
let nextLine
|
|
|
|
let nextLine
|
|
|
|
@ -114,6 +115,17 @@ module.exports = {
|
|
|
|
|
|
|
|
|
|
|
|
var zippedCode = encode64(pako.deflate('@startuml\n' + contents + '\n@enduml', { to: 'string' }))
|
|
|
|
var zippedCode = encode64(pako.deflate('@startuml\n' + contents + '\n@enduml', { to: 'string' }))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (renderSvgAsObject && imageFormat === 'svg') {
|
|
|
|
|
|
|
|
token = state.push('uml_diagram', 'object', 0)
|
|
|
|
|
|
|
|
// alt is constructed from children. No point in populating it here.
|
|
|
|
|
|
|
|
token.attrs = [['data', `${server}/${imageFormat}/${zippedCode}`], ['alt', ''], ['type', 'image/svg+xml'], ['class', 'uml-diagram']]
|
|
|
|
|
|
|
|
token.block = true
|
|
|
|
|
|
|
|
token.children = []
|
|
|
|
|
|
|
|
token.info = params
|
|
|
|
|
|
|
|
token.map = [startLine, nextLine]
|
|
|
|
|
|
|
|
token.markup = markup
|
|
|
|
|
|
|
|
state.line = nextLine + (autoClosed ? 1 : 0)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
token = state.push('uml_diagram', 'img', 0)
|
|
|
|
token = state.push('uml_diagram', 'img', 0)
|
|
|
|
// alt is constructed from children. No point in populating it here.
|
|
|
|
// alt is constructed from children. No point in populating it here.
|
|
|
|
token.attrs = [['src', `${server}/${imageFormat}/${zippedCode}`], ['alt', ''], ['class', 'uml-diagram']]
|
|
|
|
token.attrs = [['src', `${server}/${imageFormat}/${zippedCode}`], ['alt', ''], ['class', 'uml-diagram']]
|
|
|
|
@ -122,8 +134,8 @@ module.exports = {
|
|
|
|
token.info = params
|
|
|
|
token.info = params
|
|
|
|
token.map = [startLine, nextLine]
|
|
|
|
token.map = [startLine, nextLine]
|
|
|
|
token.markup = markup
|
|
|
|
token.markup = markup
|
|
|
|
|
|
|
|
|
|
|
|
state.line = nextLine + (autoClosed ? 1 : 0)
|
|
|
|
state.line = nextLine + (autoClosed ? 1 : 0)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}, {
|
|
|
|
}, {
|
|
|
|
@ -134,7 +146,8 @@ module.exports = {
|
|
|
|
openMarker: conf.openMarker,
|
|
|
|
openMarker: conf.openMarker,
|
|
|
|
closeMarker: conf.closeMarker,
|
|
|
|
closeMarker: conf.closeMarker,
|
|
|
|
imageFormat: conf.imageFormat,
|
|
|
|
imageFormat: conf.imageFormat,
|
|
|
|
server: conf.server
|
|
|
|
server: conf.server,
|
|
|
|
|
|
|
|
renderSvgAsObject: conf.renderSvgAsObject
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|