mirror of https://github.com/requarks/wiki
parent
c0df6d5b69
commit
aeef7b1e53
@ -1,8 +1,7 @@
|
||||
key: htmlAsciinema
|
||||
title: Asciinema
|
||||
description: Embed asciinema players from compatible links
|
||||
author: requarks.io
|
||||
icon: mdi-theater
|
||||
enabledDefault: false
|
||||
dependsOn: html-core
|
||||
dependsOn: core
|
||||
props: {}
|
@ -1,8 +1,7 @@
|
||||
key: htmlBlockquotes
|
||||
title: Blockquotes
|
||||
description: Parse blockquotes box styling
|
||||
author: requarks.io
|
||||
icon: mdi-alpha-t-box-outline
|
||||
enabledDefault: true
|
||||
dependsOn: html-core
|
||||
dependsOn: core
|
||||
props: {}
|
@ -1,9 +1,8 @@
|
||||
key: htmlCodehighlighter
|
||||
title: Code Highlighting Post-Processor
|
||||
description: Syntax detector for programming code
|
||||
author: requarks.io
|
||||
icon: mdi-code-braces
|
||||
enabledDefault: true
|
||||
dependsOn: html-core
|
||||
dependsOn: core
|
||||
step: pre
|
||||
props: {}
|
@ -1,9 +1,7 @@
|
||||
key: html-core
|
||||
key: core
|
||||
title: Core
|
||||
description: Basic HTML Parser
|
||||
author: requarks.io
|
||||
input: html
|
||||
output: html
|
||||
icon: mdi-language-html5
|
||||
props:
|
||||
absoluteLinks:
|
@ -0,0 +1,286 @@
|
||||
import { reject } from 'lodash-es'
|
||||
import * as cheerio from 'cheerio'
|
||||
import uslug from 'uslug'
|
||||
import pageHelper from '../../../helpers/page'
|
||||
import { URL } from 'node:url'
|
||||
|
||||
const mustacheRegExp = /(\{|{?){2}(.+?)(\}|}?){2}/i
|
||||
|
||||
export async function render () {
|
||||
const $ = cheerio.load(this.input, {
|
||||
decodeEntities: true
|
||||
})
|
||||
|
||||
if ($.root().children().length < 1) {
|
||||
return ''
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
// STEP: PRE
|
||||
// --------------------------------
|
||||
|
||||
for (const child of reject(this.children, ['step', 'post'])) {
|
||||
const renderer = (await import(`../${kebabCase(child.key)}/renderer.mjs`)).render
|
||||
await renderer($, child.config)
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
// Detect internal / external links
|
||||
// --------------------------------
|
||||
|
||||
let internalRefs = []
|
||||
const reservedPrefixes = /^\/[a-z]\//i
|
||||
const exactReservedPaths = /^\/[a-z]$/i
|
||||
|
||||
const hasHostname = this.site.hostname !== '*'
|
||||
|
||||
$('a').each((i, elm) => {
|
||||
let href = $(elm).attr('href')
|
||||
|
||||
// -> Ignore empty / anchor links, e-mail addresses, and telephone numbers
|
||||
if (!href || href.length < 1 || href.indexOf('#') === 0 ||
|
||||
href.indexOf('mailto:') === 0 || href.indexOf('tel:') === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
// -> Strip host from local links
|
||||
if (hasHostname && href.indexOf(`${this.site.hostname}/`) === 0) {
|
||||
href = href.replace(this.site.hostname, '')
|
||||
}
|
||||
|
||||
// -> Assign local / external tag
|
||||
if (href.indexOf('://') < 0) {
|
||||
// -> Remove trailing slash
|
||||
if (_.endsWith('/')) {
|
||||
href = href.slice(0, -1)
|
||||
}
|
||||
|
||||
// -> Check for system prefix
|
||||
if (reservedPrefixes.test(href) || exactReservedPaths.test(href)) {
|
||||
$(elm).addClass(`is-system-link`)
|
||||
} else if (href.indexOf('.') >= 0) {
|
||||
$(elm).addClass(`is-asset-link`)
|
||||
} else {
|
||||
let pagePath = null
|
||||
|
||||
// -> Add locale prefix if using namespacing
|
||||
if (this.site.config.localeNamespacing) {
|
||||
// -> Reformat paths
|
||||
if (href.indexOf('/') !== 0) {
|
||||
if (this.config.absoluteLinks) {
|
||||
href = `/${this.page.localeCode}/${href}`
|
||||
} else {
|
||||
href = (this.page.path === 'home') ? `/${this.page.localeCode}/${href}` : `/${this.page.localeCode}/${this.page.path}/${href}`
|
||||
}
|
||||
} else if (href.charAt(3) !== '/') {
|
||||
href = `/${this.page.localeCode}${href}`
|
||||
}
|
||||
|
||||
try {
|
||||
const parsedUrl = new URL(`http://x${href}`)
|
||||
pagePath = pageHelper.parsePath(parsedUrl.pathname)
|
||||
} catch (err) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// -> Reformat paths
|
||||
if (href.indexOf('/') !== 0) {
|
||||
if (this.config.absoluteLinks) {
|
||||
href = `/${href}`
|
||||
} else {
|
||||
href = (this.page.path === 'home') ? `/${href}` : `/${this.page.path}/${href}`
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const parsedUrl = new URL(`http://x${href}`)
|
||||
pagePath = pageHelper.parsePath(parsedUrl.pathname)
|
||||
} catch (err) {
|
||||
return
|
||||
}
|
||||
}
|
||||
// -> Save internal references
|
||||
internalRefs.push({
|
||||
localeCode: pagePath.locale,
|
||||
path: pagePath.path
|
||||
})
|
||||
|
||||
$(elm).addClass(`is-internal-link`)
|
||||
}
|
||||
} else {
|
||||
$(elm).addClass(`is-external-link`)
|
||||
if (this.config.openExternalLinkNewTab) {
|
||||
$(elm).attr('target', '_blank')
|
||||
$(elm).attr('rel', this.config.relAttributeExternalLink)
|
||||
}
|
||||
}
|
||||
|
||||
// -> Update element
|
||||
$(elm).attr('href', href)
|
||||
})
|
||||
|
||||
// --------------------------------
|
||||
// Detect internal link states
|
||||
// --------------------------------
|
||||
|
||||
const pastLinks = await this.page.$relatedQuery('links')
|
||||
|
||||
if (internalRefs.length > 0) {
|
||||
// -> Find matching pages
|
||||
const results = await WIKI.db.pages.query().column('id', 'path', 'localeCode').where(builder => {
|
||||
internalRefs.forEach((ref, idx) => {
|
||||
if (idx < 1) {
|
||||
builder.where(ref)
|
||||
} else {
|
||||
builder.orWhere(ref)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// -> Apply tag to internal links for found pages
|
||||
$('a.is-internal-link').each((i, elm) => {
|
||||
const href = $(elm).attr('href')
|
||||
let hrefObj = {}
|
||||
try {
|
||||
const parsedUrl = new URL(`http://x${href}`)
|
||||
hrefObj = pageHelper.parsePath(parsedUrl.pathname)
|
||||
} catch (err) {
|
||||
return
|
||||
}
|
||||
if (_.some(results, r => {
|
||||
return r.localeCode === hrefObj.locale && r.path === hrefObj.path
|
||||
})) {
|
||||
$(elm).addClass(`is-valid-page`)
|
||||
} else {
|
||||
$(elm).addClass(`is-invalid-page`)
|
||||
}
|
||||
})
|
||||
|
||||
// -> Add missing links
|
||||
const missingLinks = _.differenceWith(internalRefs, pastLinks, (nLink, pLink) => {
|
||||
return nLink.localeCode === pLink.localeCode && nLink.path === pLink.path
|
||||
})
|
||||
if (missingLinks.length > 0) {
|
||||
if (WIKI.config.db.type === 'postgres') {
|
||||
await WIKI.db.pageLinks.query().insert(missingLinks.map(lnk => ({
|
||||
pageId: this.page.id,
|
||||
path: lnk.path,
|
||||
localeCode: lnk.localeCode
|
||||
})))
|
||||
} else {
|
||||
for (const lnk of missingLinks) {
|
||||
await WIKI.db.pageLinks.query().insert({
|
||||
pageId: this.page.id,
|
||||
path: lnk.path,
|
||||
localeCode: lnk.localeCode
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -> Remove outdated links
|
||||
if (pastLinks) {
|
||||
const outdatedLinks = _.differenceWith(pastLinks, internalRefs, (nLink, pLink) => {
|
||||
return nLink.localeCode === pLink.localeCode && nLink.path === pLink.path
|
||||
})
|
||||
if (outdatedLinks.length > 0) {
|
||||
await WIKI.db.pageLinks.query().delete().whereIn('id', _.map(outdatedLinks, 'id'))
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
// Add header handles
|
||||
// --------------------------------
|
||||
|
||||
let headers = []
|
||||
$('h1,h2,h3,h4,h5,h6').each((i, elm) => {
|
||||
let headerSlug = uslug($(elm).text())
|
||||
// -> If custom ID is defined, try to use that instead
|
||||
if ($(elm).attr('id')) {
|
||||
headerSlug = $(elm).attr('id')
|
||||
}
|
||||
|
||||
// -> Cannot start with a number (CSS selector limitation)
|
||||
if (headerSlug.match(/^\d/)) {
|
||||
headerSlug = `h-${headerSlug}`
|
||||
}
|
||||
|
||||
// -> Make sure header is unique
|
||||
if (headers.indexOf(headerSlug) >= 0) {
|
||||
let isUnique = false
|
||||
let hIdx = 1
|
||||
while (!isUnique) {
|
||||
const headerSlugTry = `${headerSlug}-${hIdx}`
|
||||
if (headers.indexOf(headerSlugTry) < 0) {
|
||||
isUnique = true
|
||||
headerSlug = headerSlugTry
|
||||
}
|
||||
hIdx++
|
||||
}
|
||||
}
|
||||
|
||||
// -> Add anchor
|
||||
$(elm).attr('id', headerSlug).addClass('toc-header')
|
||||
$(elm).prepend(`<a class="toc-anchor" href="#${headerSlug}">¶</a> `)
|
||||
|
||||
headers.push(headerSlug)
|
||||
})
|
||||
|
||||
// --------------------------------
|
||||
// Wrap non-empty root text nodes
|
||||
// --------------------------------
|
||||
|
||||
$('body').contents().toArray().forEach(item => {
|
||||
if (item && item.type === 'text' && item.parent.name === 'body' && item.data !== `\n` && item.data !== `\r`) {
|
||||
$(item).wrap('<div></div>')
|
||||
}
|
||||
})
|
||||
|
||||
// --------------------------------
|
||||
// Escape mustache expresions
|
||||
// --------------------------------
|
||||
|
||||
function iterateMustacheNode (node) {
|
||||
const list = $(node).contents().toArray()
|
||||
list.forEach(item => {
|
||||
if (item && item.type === 'text') {
|
||||
const rawText = $(item).text().replace(/\r?\n|\r/g, '')
|
||||
if (mustacheRegExp.test(rawText)) {
|
||||
$(item).parent().attr('v-pre', true)
|
||||
}
|
||||
} else {
|
||||
iterateMustacheNode(item)
|
||||
}
|
||||
})
|
||||
}
|
||||
iterateMustacheNode($.root())
|
||||
|
||||
$('pre').each((idx, elm) => {
|
||||
$(elm).attr('v-pre', true)
|
||||
})
|
||||
|
||||
// --------------------------------
|
||||
// STEP: POST
|
||||
// --------------------------------
|
||||
|
||||
let output = decodeEscape($.html('body').replace('<body>', '').replace('</body>', ''))
|
||||
|
||||
for (let child of _.sortBy(_.filter(this.children, ['step', 'post']), ['order'])) {
|
||||
const renderer = require(`../${_.kebabCase(child.key)}/renderer.js`)
|
||||
output = await renderer.init(output, child.config)
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
function decodeEscape (string) {
|
||||
return string.replace(/&#x([0-9a-f]{1,6});/ig, (entity, code) => {
|
||||
code = parseInt(code, 16)
|
||||
|
||||
// Don't unescape ASCII characters, assuming they're encoded for a good reason
|
||||
if (code < 0x80) return entity
|
||||
|
||||
return String.fromCodePoint(code)
|
||||
})
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
key: htmlDiagram
|
||||
title: Diagrams Post-Processor
|
||||
description: HTML Processing for diagrams (draw.io)
|
||||
author: requarks.io
|
||||
icon: mdi-chart-multiline
|
||||
enabledDefault: true
|
||||
dependsOn: html-core
|
||||
dependsOn: core
|
||||
props: {}
|
@ -1,288 +0,0 @@
|
||||
const _ = require('lodash')
|
||||
const cheerio = require('cheerio')
|
||||
const uslug = require('uslug')
|
||||
const pageHelper = require('../../../helpers/page')
|
||||
const URL = require('url').URL
|
||||
|
||||
const mustacheRegExp = /(\{|{?){2}(.+?)(\}|}?){2}/i
|
||||
|
||||
export default {
|
||||
async render() {
|
||||
const $ = cheerio.load(this.input, {
|
||||
decodeEntities: true
|
||||
})
|
||||
|
||||
if ($.root().children().length < 1) {
|
||||
return ''
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
// STEP: PRE
|
||||
// --------------------------------
|
||||
|
||||
for (let child of _.reject(this.children, ['step', 'post'])) {
|
||||
const renderer = require(`../${child.key}/renderer.mjs`)
|
||||
await renderer.init($, child.config)
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
// Detect internal / external links
|
||||
// --------------------------------
|
||||
|
||||
let internalRefs = []
|
||||
const reservedPrefixes = /^\/[a-z]\//i
|
||||
const exactReservedPaths = /^\/[a-z]$/i
|
||||
|
||||
const hasHostname = this.site.hostname !== '*'
|
||||
|
||||
$('a').each((i, elm) => {
|
||||
let href = $(elm).attr('href')
|
||||
|
||||
// -> Ignore empty / anchor links, e-mail addresses, and telephone numbers
|
||||
if (!href || href.length < 1 || href.indexOf('#') === 0 ||
|
||||
href.indexOf('mailto:') === 0 || href.indexOf('tel:') === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
// -> Strip host from local links
|
||||
if (hasHostname && href.indexOf(`${this.site.hostname}/`) === 0) {
|
||||
href = href.replace(this.site.hostname, '')
|
||||
}
|
||||
|
||||
// -> Assign local / external tag
|
||||
if (href.indexOf('://') < 0) {
|
||||
// -> Remove trailing slash
|
||||
if (_.endsWith('/')) {
|
||||
href = href.slice(0, -1)
|
||||
}
|
||||
|
||||
// -> Check for system prefix
|
||||
if (reservedPrefixes.test(href) || exactReservedPaths.test(href)) {
|
||||
$(elm).addClass(`is-system-link`)
|
||||
} else if (href.indexOf('.') >= 0) {
|
||||
$(elm).addClass(`is-asset-link`)
|
||||
} else {
|
||||
let pagePath = null
|
||||
|
||||
// -> Add locale prefix if using namespacing
|
||||
if (this.site.config.localeNamespacing) {
|
||||
// -> Reformat paths
|
||||
if (href.indexOf('/') !== 0) {
|
||||
if (this.config.absoluteLinks) {
|
||||
href = `/${this.page.localeCode}/${href}`
|
||||
} else {
|
||||
href = (this.page.path === 'home') ? `/${this.page.localeCode}/${href}` : `/${this.page.localeCode}/${this.page.path}/${href}`
|
||||
}
|
||||
} else if (href.charAt(3) !== '/') {
|
||||
href = `/${this.page.localeCode}${href}`
|
||||
}
|
||||
|
||||
try {
|
||||
const parsedUrl = new URL(`http://x${href}`)
|
||||
pagePath = pageHelper.parsePath(parsedUrl.pathname)
|
||||
} catch (err) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// -> Reformat paths
|
||||
if (href.indexOf('/') !== 0) {
|
||||
if (this.config.absoluteLinks) {
|
||||
href = `/${href}`
|
||||
} else {
|
||||
href = (this.page.path === 'home') ? `/${href}` : `/${this.page.path}/${href}`
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const parsedUrl = new URL(`http://x${href}`)
|
||||
pagePath = pageHelper.parsePath(parsedUrl.pathname)
|
||||
} catch (err) {
|
||||
return
|
||||
}
|
||||
}
|
||||
// -> Save internal references
|
||||
internalRefs.push({
|
||||
localeCode: pagePath.locale,
|
||||
path: pagePath.path
|
||||
})
|
||||
|
||||
$(elm).addClass(`is-internal-link`)
|
||||
}
|
||||
} else {
|
||||
$(elm).addClass(`is-external-link`)
|
||||
if (this.config.openExternalLinkNewTab) {
|
||||
$(elm).attr('target', '_blank')
|
||||
$(elm).attr('rel', this.config.relAttributeExternalLink)
|
||||
}
|
||||
}
|
||||
|
||||
// -> Update element
|
||||
$(elm).attr('href', href)
|
||||
})
|
||||
|
||||
// --------------------------------
|
||||
// Detect internal link states
|
||||
// --------------------------------
|
||||
|
||||
const pastLinks = await this.page.$relatedQuery('links')
|
||||
|
||||
if (internalRefs.length > 0) {
|
||||
// -> Find matching pages
|
||||
const results = await WIKI.db.pages.query().column('id', 'path', 'localeCode').where(builder => {
|
||||
internalRefs.forEach((ref, idx) => {
|
||||
if (idx < 1) {
|
||||
builder.where(ref)
|
||||
} else {
|
||||
builder.orWhere(ref)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// -> Apply tag to internal links for found pages
|
||||
$('a.is-internal-link').each((i, elm) => {
|
||||
const href = $(elm).attr('href')
|
||||
let hrefObj = {}
|
||||
try {
|
||||
const parsedUrl = new URL(`http://x${href}`)
|
||||
hrefObj = pageHelper.parsePath(parsedUrl.pathname)
|
||||
} catch (err) {
|
||||
return
|
||||
}
|
||||
if (_.some(results, r => {
|
||||
return r.localeCode === hrefObj.locale && r.path === hrefObj.path
|
||||
})) {
|
||||
$(elm).addClass(`is-valid-page`)
|
||||
} else {
|
||||
$(elm).addClass(`is-invalid-page`)
|
||||
}
|
||||
})
|
||||
|
||||
// -> Add missing links
|
||||
const missingLinks = _.differenceWith(internalRefs, pastLinks, (nLink, pLink) => {
|
||||
return nLink.localeCode === pLink.localeCode && nLink.path === pLink.path
|
||||
})
|
||||
if (missingLinks.length > 0) {
|
||||
if (WIKI.config.db.type === 'postgres') {
|
||||
await WIKI.db.pageLinks.query().insert(missingLinks.map(lnk => ({
|
||||
pageId: this.page.id,
|
||||
path: lnk.path,
|
||||
localeCode: lnk.localeCode
|
||||
})))
|
||||
} else {
|
||||
for (const lnk of missingLinks) {
|
||||
await WIKI.db.pageLinks.query().insert({
|
||||
pageId: this.page.id,
|
||||
path: lnk.path,
|
||||
localeCode: lnk.localeCode
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -> Remove outdated links
|
||||
if (pastLinks) {
|
||||
const outdatedLinks = _.differenceWith(pastLinks, internalRefs, (nLink, pLink) => {
|
||||
return nLink.localeCode === pLink.localeCode && nLink.path === pLink.path
|
||||
})
|
||||
if (outdatedLinks.length > 0) {
|
||||
await WIKI.db.pageLinks.query().delete().whereIn('id', _.map(outdatedLinks, 'id'))
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
// Add header handles
|
||||
// --------------------------------
|
||||
|
||||
let headers = []
|
||||
$('h1,h2,h3,h4,h5,h6').each((i, elm) => {
|
||||
let headerSlug = uslug($(elm).text())
|
||||
// -> If custom ID is defined, try to use that instead
|
||||
if ($(elm).attr('id')) {
|
||||
headerSlug = $(elm).attr('id')
|
||||
}
|
||||
|
||||
// -> Cannot start with a number (CSS selector limitation)
|
||||
if (headerSlug.match(/^\d/)) {
|
||||
headerSlug = `h-${headerSlug}`
|
||||
}
|
||||
|
||||
// -> Make sure header is unique
|
||||
if (headers.indexOf(headerSlug) >= 0) {
|
||||
let isUnique = false
|
||||
let hIdx = 1
|
||||
while (!isUnique) {
|
||||
const headerSlugTry = `${headerSlug}-${hIdx}`
|
||||
if (headers.indexOf(headerSlugTry) < 0) {
|
||||
isUnique = true
|
||||
headerSlug = headerSlugTry
|
||||
}
|
||||
hIdx++
|
||||
}
|
||||
}
|
||||
|
||||
// -> Add anchor
|
||||
$(elm).attr('id', headerSlug).addClass('toc-header')
|
||||
$(elm).prepend(`<a class="toc-anchor" href="#${headerSlug}">¶</a> `)
|
||||
|
||||
headers.push(headerSlug)
|
||||
})
|
||||
|
||||
// --------------------------------
|
||||
// Wrap non-empty root text nodes
|
||||
// --------------------------------
|
||||
|
||||
$('body').contents().toArray().forEach(item => {
|
||||
if (item && item.type === 'text' && item.parent.name === 'body' && item.data !== `\n` && item.data !== `\r`) {
|
||||
$(item).wrap('<div></div>')
|
||||
}
|
||||
})
|
||||
|
||||
// --------------------------------
|
||||
// Escape mustache expresions
|
||||
// --------------------------------
|
||||
|
||||
function iterateMustacheNode (node) {
|
||||
const list = $(node).contents().toArray()
|
||||
list.forEach(item => {
|
||||
if (item && item.type === 'text') {
|
||||
const rawText = $(item).text().replace(/\r?\n|\r/g, '')
|
||||
if (mustacheRegExp.test(rawText)) {
|
||||
$(item).parent().attr('v-pre', true)
|
||||
}
|
||||
} else {
|
||||
iterateMustacheNode(item)
|
||||
}
|
||||
})
|
||||
}
|
||||
iterateMustacheNode($.root())
|
||||
|
||||
$('pre').each((idx, elm) => {
|
||||
$(elm).attr('v-pre', true)
|
||||
})
|
||||
|
||||
// --------------------------------
|
||||
// STEP: POST
|
||||
// --------------------------------
|
||||
|
||||
let output = decodeEscape($.html('body').replace('<body>', '').replace('</body>', ''))
|
||||
|
||||
for (let child of _.sortBy(_.filter(this.children, ['step', 'post']), ['order'])) {
|
||||
const renderer = require(`../${_.kebabCase(child.key)}/renderer.js`)
|
||||
output = await renderer.init(output, child.config)
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
}
|
||||
|
||||
function decodeEscape (string) {
|
||||
return string.replace(/&#x([0-9a-f]{1,6});/ig, (entity, code) => {
|
||||
code = parseInt(code, 16)
|
||||
|
||||
// Don't unescape ASCII characters, assuming they're encoded for a good reason
|
||||
if (code < 0x80) return entity
|
||||
|
||||
return String.fromCodePoint(code)
|
||||
})
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
key: htmlImagePrefetch
|
||||
title: Image Prefetch
|
||||
description: Prefetch remotely rendered images (korki/plantuml)
|
||||
author: requarks.io
|
||||
icon: mdi-cloud-download-outline
|
||||
enabledDefault: false
|
||||
dependsOn: html-core
|
||||
dependsOn: core
|
||||
props: {}
|
@ -1,8 +1,7 @@
|
||||
key: htmlMediaplayers
|
||||
title: Media Players
|
||||
description: Embed players such as Youtube, Vimeo, Soundcloud, etc.
|
||||
author: requarks.io
|
||||
icon: mdi-video
|
||||
enabledDefault: true
|
||||
dependsOn: html-core
|
||||
dependsOn: core
|
||||
props: {}
|
@ -1,8 +1,7 @@
|
||||
key: htmlMermaid
|
||||
title: Mermaid
|
||||
description: Generate flowcharts from Mermaid syntax
|
||||
author: requarks.io
|
||||
icon: mdi-arrow-decision-outline
|
||||
enabledDefault: true
|
||||
dependsOn: html-core
|
||||
dependsOn: core
|
||||
props: {}
|
@ -1,10 +1,9 @@
|
||||
key: htmlSecurity
|
||||
title: Security
|
||||
description: Filter and strips potentially dangerous content
|
||||
author: requarks.io
|
||||
icon: mdi-fire
|
||||
enabledDefault: true
|
||||
dependsOn: html-core
|
||||
dependsOn: core
|
||||
step: post
|
||||
order: 99999
|
||||
props:
|
@ -1,8 +1,7 @@
|
||||
key: htmlTabset
|
||||
title: Tabsets
|
||||
description: Transform headers into tabs
|
||||
author: requarks.io
|
||||
icon: mdi-tab
|
||||
enabledDefault: true
|
||||
dependsOn: html-core
|
||||
dependsOn: core
|
||||
props: {}
|
@ -1,10 +1,9 @@
|
||||
key: htmlTwemoji
|
||||
title: Twemoji
|
||||
description: Apply Twitter Emojis to all Unicode emojis
|
||||
author: requarks.io
|
||||
icon: mdi-emoticon-happy-outline
|
||||
enabledDefault: true
|
||||
dependsOn: html-core
|
||||
dependsOn: core
|
||||
step: post
|
||||
order: 10
|
||||
props: {}
|
@ -0,0 +1,145 @@
|
||||
// Test if potential opening or closing delimieter
|
||||
// Assumes that there is a "$" at state.src[pos]
|
||||
function isValidDelim (state, pos) {
|
||||
const max = state.posMax
|
||||
let canOpen = true
|
||||
let canClose = true
|
||||
|
||||
const prevChar = pos > 0 ? state.src.charCodeAt(pos - 1) : -1
|
||||
const nextChar = pos + 1 <= max ? state.src.charCodeAt(pos + 1) : -1
|
||||
|
||||
// Check non-whitespace conditions for opening and closing, and
|
||||
// check that closing delimeter isn't followed by a number
|
||||
if (prevChar === 0x20/* " " */ || prevChar === 0x09/* \t */ ||
|
||||
(nextChar >= 0x30/* "0" */ && nextChar <= 0x39/* "9" */)) {
|
||||
canClose = false
|
||||
}
|
||||
if (nextChar === 0x20/* " " */ || nextChar === 0x09/* \t */) {
|
||||
canOpen = false
|
||||
}
|
||||
|
||||
return {
|
||||
canOpen,
|
||||
canClose
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
katexInline (state, silent) {
|
||||
let match, token, res, pos
|
||||
|
||||
if (state.src[state.pos] !== '$') { return false }
|
||||
|
||||
res = isValidDelim(state, state.pos)
|
||||
if (!res.canOpen) {
|
||||
if (!silent) { state.pending += '$' }
|
||||
state.pos += 1
|
||||
return true
|
||||
}
|
||||
|
||||
// First check for and bypass all properly escaped delimieters
|
||||
// This loop will assume that the first leading backtick can not
|
||||
// be the first character in state.src, which is known since
|
||||
// we have found an opening delimieter already.
|
||||
const start = state.pos + 1
|
||||
match = start
|
||||
while ((match = state.src.indexOf('$', match)) !== -1) {
|
||||
// Found potential $, look for escapes, pos will point to
|
||||
// first non escape when complete
|
||||
pos = match - 1
|
||||
while (state.src[pos] === '\\') { pos -= 1 }
|
||||
|
||||
// Even number of escapes, potential closing delimiter found
|
||||
if (((match - pos) % 2) === 1) { break }
|
||||
match += 1
|
||||
}
|
||||
|
||||
// No closing delimter found. Consume $ and continue.
|
||||
if (match === -1) {
|
||||
if (!silent) { state.pending += '$' }
|
||||
state.pos = start
|
||||
return true
|
||||
}
|
||||
|
||||
// Check if we have empty content, ie: $$. Do not parse.
|
||||
if (match - start === 0) {
|
||||
if (!silent) { state.pending += '$$' }
|
||||
state.pos = start + 1
|
||||
return true
|
||||
}
|
||||
|
||||
// Check for valid closing delimiter
|
||||
res = isValidDelim(state, match)
|
||||
if (!res.canClose) {
|
||||
if (!silent) { state.pending += '$' }
|
||||
state.pos = start
|
||||
return true
|
||||
}
|
||||
|
||||
if (!silent) {
|
||||
token = state.push('katex_inline', 'math', 0)
|
||||
token.markup = '$'
|
||||
token.content = state.src
|
||||
// Extract the math part without the $
|
||||
.slice(start, match)
|
||||
// Escape the curly braces since they will be interpreted as
|
||||
// attributes by markdown-it-attrs (the "curly_attributes"
|
||||
// core rule)
|
||||
.replaceAll('{', '{{')
|
||||
.replaceAll('}', '}}')
|
||||
}
|
||||
|
||||
state.pos = match + 1
|
||||
return true
|
||||
},
|
||||
|
||||
katexBlock (state, start, end, silent) {
|
||||
let firstLine; let lastLine; let next; let lastPos; let found = false
|
||||
let pos = state.bMarks[start] + state.tShift[start]
|
||||
let max = state.eMarks[start]
|
||||
|
||||
if (pos + 2 > max) { return false }
|
||||
if (state.src.slice(pos, pos + 2) !== '$$') { return false }
|
||||
|
||||
pos += 2
|
||||
firstLine = state.src.slice(pos, max)
|
||||
|
||||
if (silent) { return true }
|
||||
if (firstLine.trim().slice(-2) === '$$') {
|
||||
// Single line expression
|
||||
firstLine = firstLine.trim().slice(0, -2)
|
||||
found = true
|
||||
}
|
||||
|
||||
for (next = start; !found;) {
|
||||
next++
|
||||
|
||||
if (next >= end) { break }
|
||||
|
||||
pos = state.bMarks[next] + state.tShift[next]
|
||||
max = state.eMarks[next]
|
||||
|
||||
if (pos < max && state.tShift[next] < state.blkIndent) {
|
||||
// non-empty line with negative indent should stop the list:
|
||||
break
|
||||
}
|
||||
|
||||
if (state.src.slice(pos, max).trim().slice(-2) === '$$') {
|
||||
lastPos = state.src.slice(0, max).lastIndexOf('$$')
|
||||
lastLine = state.src.slice(pos, lastPos)
|
||||
found = true
|
||||
}
|
||||
}
|
||||
|
||||
state.line = next + 1
|
||||
|
||||
const token = state.push('katex_block', 'math', 0)
|
||||
token.block = true
|
||||
token.content = (firstLine && firstLine.trim() ? firstLine + '\n' : '') +
|
||||
state.getLines(start + 1, next, state.tShift[start], true) +
|
||||
(lastLine && lastLine.trim() ? lastLine : '')
|
||||
token.map = [start, state.line]
|
||||
token.markup = '$$'
|
||||
return true
|
||||
}
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
import pako from 'pako'
|
||||
|
||||
// ------------------------------------
|
||||
// Markdown - PlantUML Preprocessor
|
||||
// ------------------------------------
|
||||
|
||||
export default {
|
||||
init (mdinst, conf) {
|
||||
mdinst.use((md, opts) => {
|
||||
const openMarker = opts.openMarker || '```kroki'
|
||||
const openChar = openMarker.charCodeAt(0)
|
||||
const closeMarker = opts.closeMarker || '```'
|
||||
const closeChar = closeMarker.charCodeAt(0)
|
||||
const server = opts.server || 'https://kroki.io'
|
||||
|
||||
md.block.ruler.before('fence', 'kroki', (state, startLine, endLine, silent) => {
|
||||
let nextLine
|
||||
let markup
|
||||
let params
|
||||
let token
|
||||
let i
|
||||
let autoClosed = false
|
||||
let start = state.bMarks[startLine] + state.tShift[startLine]
|
||||
let max = state.eMarks[startLine]
|
||||
|
||||
// Check out the first character quickly,
|
||||
// this should filter out most of non-uml blocks
|
||||
//
|
||||
if (openChar !== state.src.charCodeAt(start)) { return false }
|
||||
|
||||
// Check out the rest of the marker string
|
||||
//
|
||||
for (i = 0; i < openMarker.length; ++i) {
|
||||
if (openMarker[i] !== state.src[start + i]) { return false }
|
||||
}
|
||||
|
||||
markup = state.src.slice(start, start + i)
|
||||
params = state.src.slice(start + i, max)
|
||||
|
||||
// Since start is found, we can report success here in validation mode
|
||||
//
|
||||
if (silent) { return true }
|
||||
|
||||
// Search for the end of the block
|
||||
//
|
||||
nextLine = startLine
|
||||
|
||||
for (;;) {
|
||||
nextLine++
|
||||
if (nextLine >= endLine) {
|
||||
// unclosed block should be autoclosed by end of document.
|
||||
// also block seems to be autoclosed by end of parent
|
||||
break
|
||||
}
|
||||
|
||||
start = state.bMarks[nextLine] + state.tShift[nextLine]
|
||||
max = state.eMarks[nextLine]
|
||||
|
||||
if (start < max && state.sCount[nextLine] < state.blkIndent) {
|
||||
// non-empty line with negative indent should stop the list:
|
||||
// - ```
|
||||
// test
|
||||
break
|
||||
}
|
||||
|
||||
if (closeChar !== state.src.charCodeAt(start)) {
|
||||
// didn't find the closing fence
|
||||
continue
|
||||
}
|
||||
|
||||
if (state.sCount[nextLine] > state.sCount[startLine]) {
|
||||
// closing fence should not be indented with respect of opening fence
|
||||
continue
|
||||
}
|
||||
|
||||
let closeMarkerMatched = true
|
||||
for (i = 0; i < closeMarker.length; ++i) {
|
||||
if (closeMarker[i] !== state.src[start + i]) {
|
||||
closeMarkerMatched = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (!closeMarkerMatched) {
|
||||
continue
|
||||
}
|
||||
|
||||
// make sure tail has spaces only
|
||||
if (state.skipSpaces(start + i) < max) {
|
||||
continue
|
||||
}
|
||||
|
||||
// found!
|
||||
autoClosed = true
|
||||
break
|
||||
}
|
||||
|
||||
let contents = state.src
|
||||
.split('\n')
|
||||
.slice(startLine + 1, nextLine)
|
||||
.join('\n')
|
||||
|
||||
// We generate a token list for the alt property, to mimic what the image parser does.
|
||||
let altToken = []
|
||||
// Remove leading space if any.
|
||||
let alt = params ? params.slice(1) : 'uml diagram'
|
||||
state.md.inline.parse(
|
||||
alt,
|
||||
state.md,
|
||||
state.env,
|
||||
altToken
|
||||
)
|
||||
|
||||
let firstlf = contents.indexOf('\n')
|
||||
if (firstlf === -1) firstlf = undefined
|
||||
let diagramType = contents.substring(0, firstlf)
|
||||
contents = contents.substring(firstlf + 1)
|
||||
|
||||
const result = pako.deflate(contents).toString('base64').replace(/\+/g, '-').replace(/\//g, '_')
|
||||
|
||||
token = state.push('kroki', 'img', 0)
|
||||
// alt is constructed from children. No point in populating it here.
|
||||
token.attrs = [ [ 'src', `${server}/${diagramType}/svg/${result}` ], [ 'alt', '' ], ['class', 'uml-diagram prefetch-candidate'] ]
|
||||
token.block = true
|
||||
token.children = altToken
|
||||
token.info = params
|
||||
token.map = [ startLine, nextLine ]
|
||||
token.markup = markup
|
||||
|
||||
state.line = nextLine + (autoClosed ? 1 : 0)
|
||||
|
||||
return true
|
||||
}, {
|
||||
alt: [ 'paragraph', 'reference', 'blockquote', 'list' ]
|
||||
})
|
||||
md.renderer.rules.kroki = md.renderer.rules.image
|
||||
}, {
|
||||
openMarker: conf.openMarker,
|
||||
closeMarker: conf.closeMarker,
|
||||
server: conf.server
|
||||
})
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
function renderEm (tokens, idx, opts, env, slf) {
|
||||
const token = tokens[idx]
|
||||
if (token.markup === '_') {
|
||||
token.tag = 'u'
|
||||
}
|
||||
return slf.renderToken(tokens, idx, opts)
|
||||
}
|
||||
|
||||
export default (md) => {
|
||||
md.renderer.rules.em_open = renderEm
|
||||
md.renderer.rules.em_close = renderEm
|
||||
}
|
@ -0,0 +1,187 @@
|
||||
import pako from 'pako'
|
||||
|
||||
// ------------------------------------
|
||||
// Markdown - PlantUML Preprocessor
|
||||
// ------------------------------------
|
||||
|
||||
export default {
|
||||
init (mdinst, conf) {
|
||||
mdinst.use((md, opts) => {
|
||||
const openMarker = opts.openMarker || '```plantuml'
|
||||
const openChar = openMarker.charCodeAt(0)
|
||||
const closeMarker = opts.closeMarker || '```'
|
||||
const closeChar = closeMarker.charCodeAt(0)
|
||||
const imageFormat = opts.imageFormat || 'svg'
|
||||
const server = opts.server || 'https://plantuml.requarks.io'
|
||||
|
||||
md.block.ruler.before('fence', 'uml_diagram', (state, startLine, endLine, silent) => {
|
||||
let nextLine
|
||||
let i
|
||||
let autoClosed = false
|
||||
let start = state.bMarks[startLine] + state.tShift[startLine]
|
||||
let max = state.eMarks[startLine]
|
||||
|
||||
// Check out the first character quickly,
|
||||
// this should filter out most of non-uml blocks
|
||||
//
|
||||
if (openChar !== state.src.charCodeAt(start)) { return false }
|
||||
|
||||
// Check out the rest of the marker string
|
||||
//
|
||||
for (i = 0; i < openMarker.length; ++i) {
|
||||
if (openMarker[i] !== state.src[start + i]) { return false }
|
||||
}
|
||||
|
||||
const markup = state.src.slice(start, start + i)
|
||||
const params = state.src.slice(start + i, max)
|
||||
|
||||
// Since start is found, we can report success here in validation mode
|
||||
//
|
||||
if (silent) { return true }
|
||||
|
||||
// Search for the end of the block
|
||||
//
|
||||
nextLine = startLine
|
||||
|
||||
for (;;) {
|
||||
nextLine++
|
||||
if (nextLine >= endLine) {
|
||||
// unclosed block should be autoclosed by end of document.
|
||||
// also block seems to be autoclosed by end of parent
|
||||
break
|
||||
}
|
||||
|
||||
start = state.bMarks[nextLine] + state.tShift[nextLine]
|
||||
max = state.eMarks[nextLine]
|
||||
|
||||
if (start < max && state.sCount[nextLine] < state.blkIndent) {
|
||||
// non-empty line with negative indent should stop the list:
|
||||
// - ```
|
||||
// test
|
||||
break
|
||||
}
|
||||
|
||||
if (closeChar !== state.src.charCodeAt(start)) {
|
||||
// didn't find the closing fence
|
||||
continue
|
||||
}
|
||||
|
||||
if (state.sCount[nextLine] > state.sCount[startLine]) {
|
||||
// closing fence should not be indented with respect of opening fence
|
||||
continue
|
||||
}
|
||||
|
||||
let closeMarkerMatched = true
|
||||
for (i = 0; i < closeMarker.length; ++i) {
|
||||
if (closeMarker[i] !== state.src[start + i]) {
|
||||
closeMarkerMatched = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (!closeMarkerMatched) {
|
||||
continue
|
||||
}
|
||||
|
||||
// make sure tail has spaces only
|
||||
if (state.skipSpaces(start + i) < max) {
|
||||
continue
|
||||
}
|
||||
|
||||
// found!
|
||||
autoClosed = true
|
||||
break
|
||||
}
|
||||
|
||||
const contents = state.src
|
||||
.split('\n')
|
||||
.slice(startLine + 1, nextLine)
|
||||
.join('\n')
|
||||
|
||||
// We generate a token list for the alt property, to mimic what the image parser does.
|
||||
const altToken = []
|
||||
// Remove leading space if any.
|
||||
const alt = params ? params.slice(1) : 'uml diagram'
|
||||
state.md.inline.parse(
|
||||
alt,
|
||||
state.md,
|
||||
state.env,
|
||||
altToken
|
||||
)
|
||||
|
||||
const zippedCode = encode64(pako.deflate('@startuml\n' + contents + '\n@enduml', { to: 'string' }))
|
||||
|
||||
const token = state.push('uml_diagram', 'img', 0)
|
||||
// alt is constructed from children. No point in populating it here.
|
||||
token.attrs = [['src', `${server}/${imageFormat}/${zippedCode}`], ['alt', ''], ['class', 'uml-diagram']]
|
||||
token.block = true
|
||||
token.children = altToken
|
||||
token.info = params
|
||||
token.map = [startLine, nextLine]
|
||||
token.markup = markup
|
||||
|
||||
state.line = nextLine + (autoClosed ? 1 : 0)
|
||||
|
||||
return true
|
||||
}, {
|
||||
alt: ['paragraph', 'reference', 'blockquote', 'list']
|
||||
})
|
||||
md.renderer.rules.uml_diagram = md.renderer.rules.image
|
||||
}, {
|
||||
openMarker: conf.openMarker,
|
||||
closeMarker: conf.closeMarker,
|
||||
imageFormat: conf.imageFormat,
|
||||
server: conf.server
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function encode64 (data) {
|
||||
let r = ''
|
||||
for (let i = 0; i < data.length; i += 3) {
|
||||
if (i + 2 === data.length) {
|
||||
r += append3bytes(data.charCodeAt(i), data.charCodeAt(i + 1), 0)
|
||||
} else if (i + 1 === data.length) {
|
||||
r += append3bytes(data.charCodeAt(i), 0, 0)
|
||||
} else {
|
||||
r += append3bytes(data.charCodeAt(i), data.charCodeAt(i + 1), data.charCodeAt(i + 2))
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
function append3bytes (b1, b2, b3) {
|
||||
const c1 = b1 >> 2
|
||||
const c2 = ((b1 & 0x3) << 4) | (b2 >> 4)
|
||||
const c3 = ((b2 & 0xF) << 2) | (b3 >> 6)
|
||||
const c4 = b3 & 0x3F
|
||||
let r = ''
|
||||
r += encode6bit(c1 & 0x3F)
|
||||
r += encode6bit(c2 & 0x3F)
|
||||
r += encode6bit(c3 & 0x3F)
|
||||
r += encode6bit(c4 & 0x3F)
|
||||
return r
|
||||
}
|
||||
|
||||
function encode6bit (raw) {
|
||||
let b = raw
|
||||
if (b < 10) {
|
||||
return String.fromCharCode(48 + b)
|
||||
}
|
||||
b -= 10
|
||||
if (b < 26) {
|
||||
return String.fromCharCode(65 + b)
|
||||
}
|
||||
b -= 26
|
||||
if (b < 26) {
|
||||
return String.fromCharCode(97 + b)
|
||||
}
|
||||
b -= 26
|
||||
if (b === 0) {
|
||||
return '-'
|
||||
}
|
||||
if (b === 1) {
|
||||
return '_'
|
||||
}
|
||||
return '?'
|
||||
}
|
After Width: | Height: | Size: 1.0 KiB |
@ -0,0 +1,143 @@
|
||||
import pako from 'pako'
|
||||
|
||||
// ------------------------------------
|
||||
// Markdown - PlantUML Preprocessor
|
||||
// ------------------------------------
|
||||
|
||||
export default {
|
||||
init (mdinst, conf) {
|
||||
mdinst.use((md, opts) => {
|
||||
const openMarker = opts.openMarker || '```kroki'
|
||||
const openChar = openMarker.charCodeAt(0)
|
||||
const closeMarker = opts.closeMarker || '```'
|
||||
const closeChar = closeMarker.charCodeAt(0)
|
||||
const server = opts.server || 'https://kroki.io'
|
||||
|
||||
md.block.ruler.before('fence', 'kroki', (state, startLine, endLine, silent) => {
|
||||
let nextLine
|
||||
let markup
|
||||
let params
|
||||
let token
|
||||
let i
|
||||
let autoClosed = false
|
||||
let start = state.bMarks[startLine] + state.tShift[startLine]
|
||||
let max = state.eMarks[startLine]
|
||||
|
||||
// Check out the first character quickly,
|
||||
// this should filter out most of non-uml blocks
|
||||
//
|
||||
if (openChar !== state.src.charCodeAt(start)) { return false }
|
||||
|
||||
// Check out the rest of the marker string
|
||||
//
|
||||
for (i = 0; i < openMarker.length; ++i) {
|
||||
if (openMarker[i] !== state.src[start + i]) { return false }
|
||||
}
|
||||
|
||||
markup = state.src.slice(start, start + i)
|
||||
params = state.src.slice(start + i, max)
|
||||
|
||||
// Since start is found, we can report success here in validation mode
|
||||
//
|
||||
if (silent) { return true }
|
||||
|
||||
// Search for the end of the block
|
||||
//
|
||||
nextLine = startLine
|
||||
|
||||
for (;;) {
|
||||
nextLine++
|
||||
if (nextLine >= endLine) {
|
||||
// unclosed block should be autoclosed by end of document.
|
||||
// also block seems to be autoclosed by end of parent
|
||||
break
|
||||
}
|
||||
|
||||
start = state.bMarks[nextLine] + state.tShift[nextLine]
|
||||
max = state.eMarks[nextLine]
|
||||
|
||||
if (start < max && state.sCount[nextLine] < state.blkIndent) {
|
||||
// non-empty line with negative indent should stop the list:
|
||||
// - ```
|
||||
// test
|
||||
break
|
||||
}
|
||||
|
||||
if (closeChar !== state.src.charCodeAt(start)) {
|
||||
// didn't find the closing fence
|
||||
continue
|
||||
}
|
||||
|
||||
if (state.sCount[nextLine] > state.sCount[startLine]) {
|
||||
// closing fence should not be indented with respect of opening fence
|
||||
continue
|
||||
}
|
||||
|
||||
let closeMarkerMatched = true
|
||||
for (i = 0; i < closeMarker.length; ++i) {
|
||||
if (closeMarker[i] !== state.src[start + i]) {
|
||||
closeMarkerMatched = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (!closeMarkerMatched) {
|
||||
continue
|
||||
}
|
||||
|
||||
// make sure tail has spaces only
|
||||
if (state.skipSpaces(start + i) < max) {
|
||||
continue
|
||||
}
|
||||
|
||||
// found!
|
||||
autoClosed = true
|
||||
break
|
||||
}
|
||||
|
||||
let contents = state.src
|
||||
.split('\n')
|
||||
.slice(startLine + 1, nextLine)
|
||||
.join('\n')
|
||||
|
||||
// We generate a token list for the alt property, to mimic what the image parser does.
|
||||
let altToken = []
|
||||
// Remove leading space if any.
|
||||
let alt = params ? params.slice(1) : 'uml diagram'
|
||||
state.md.inline.parse(
|
||||
alt,
|
||||
state.md,
|
||||
state.env,
|
||||
altToken
|
||||
)
|
||||
|
||||
let firstlf = contents.indexOf('\n')
|
||||
if (firstlf === -1) firstlf = undefined
|
||||
let diagramType = contents.substring(0, firstlf)
|
||||
contents = contents.substring(firstlf + 1)
|
||||
|
||||
const result = pako.deflate(contents).toString('base64').replace(/\+/g, '-').replace(/\//g, '_')
|
||||
|
||||
token = state.push('kroki', 'img', 0)
|
||||
// alt is constructed from children. No point in populating it here.
|
||||
token.attrs = [ [ 'src', `${server}/${diagramType}/svg/${result}` ], [ 'alt', '' ], ['class', 'uml-diagram prefetch-candidate'] ]
|
||||
token.block = true
|
||||
token.children = altToken
|
||||
token.info = params
|
||||
token.map = [ startLine, nextLine ]
|
||||
token.markup = markup
|
||||
|
||||
state.line = nextLine + (autoClosed ? 1 : 0)
|
||||
|
||||
return true
|
||||
}, {
|
||||
alt: [ 'paragraph', 'reference', 'blockquote', 'list' ]
|
||||
})
|
||||
md.renderer.rules.kroki = md.renderer.rules.image
|
||||
}, {
|
||||
openMarker: conf.openMarker,
|
||||
closeMarker: conf.closeMarker,
|
||||
server: conf.server
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Reference in new issue