mirror of
https://github.com/status-im/codimd.git
synced 2025-02-25 20:45:19 +00:00
Render plantuml only in fence
Signed-off-by: Chulki Lee <chulki.lee@gmail.com>
This commit is contained in:
parent
1d7895c869
commit
5ce981859e
@ -90,7 +90,6 @@
|
||||
"markdown-it-ins": "~2.0.0",
|
||||
"markdown-it-mark": "~2.0.0",
|
||||
"markdown-it-mathjax": "~2.0.0",
|
||||
"markdown-it-plantuml": "^1.4.1",
|
||||
"markdown-it-regexp": "~0.4.0",
|
||||
"markdown-it-sub": "~1.0.0",
|
||||
"markdown-it-sup": "~1.0.0",
|
||||
@ -119,6 +118,7 @@
|
||||
"pdfobject": "~2.0.201604172",
|
||||
"pg": "~6.1.2",
|
||||
"pg-hstore": "~2.3.2",
|
||||
"plantuml-encoder": "^1.2.5",
|
||||
"prismjs": "~1.6.0",
|
||||
"randomcolor": "~0.5.3",
|
||||
"raphael": "~2.2.8",
|
||||
|
@ -31,6 +31,8 @@ require('prismjs/components/prism-gherkin')
|
||||
require('./lib/common/login')
|
||||
require('../vendor/md-toc')
|
||||
var Viz = require('viz.js')
|
||||
const plantumlEncoder = require('plantuml-encoder')
|
||||
|
||||
const ui = getUIElements()
|
||||
|
||||
// auto update last change
|
||||
@ -970,10 +972,6 @@ md.use(require('markdown-it-emoji'), {
|
||||
shortcuts: {}
|
||||
})
|
||||
|
||||
md.use(require('markdown-it-plantuml'), {
|
||||
server: plantumlServer
|
||||
})
|
||||
|
||||
window.emojify.setConfig({
|
||||
blacklist: {
|
||||
elements: ['script', 'textarea', 'a', 'pre', 'code', 'svg'],
|
||||
@ -1040,6 +1038,33 @@ md.renderer.rules.fence = (tokens, idx, options, env, self) => {
|
||||
return `<pre><code${self.renderAttrs(token)}>${highlighted}</code></pre>\n`
|
||||
}
|
||||
|
||||
const makePlantumlURL = (umlCode) => {
|
||||
let format = 'svg'
|
||||
let code = plantumlEncoder.encode(umlCode)
|
||||
return `${plantumlServer}/${format}/${code}`
|
||||
}
|
||||
|
||||
// https://github.com/qjebbs/vscode-plantuml/tree/master/src/markdown-it-plantuml
|
||||
md.renderer.rules.plantuml = (tokens, idx) => {
|
||||
let token = tokens[idx]
|
||||
if (token.type !== 'plantuml') {
|
||||
return tokens[idx].content
|
||||
}
|
||||
|
||||
let url = makePlantumlURL(token.content)
|
||||
return `<img src="${url}" />`
|
||||
}
|
||||
|
||||
// https://github.com/qjebbs/vscode-plantuml/tree/master/src/markdown-it-plantuml
|
||||
md.core.ruler.push('plantuml', (state) => {
|
||||
let blockTokens = state.tokens
|
||||
for (let blockToken of blockTokens) {
|
||||
if (blockToken.type === 'fence' && blockToken.info === 'plantuml') {
|
||||
blockToken.type = 'plantuml'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// youtube
|
||||
const youtubePlugin = new Plugin(
|
||||
// regexp to match
|
||||
|
23
yarn.lock
23
yarn.lock
@ -7898,11 +7898,6 @@ markdown-it-mathjax@~2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/markdown-it-mathjax/-/markdown-it-mathjax-2.0.0.tgz#ae2b4f4c5c719a03f9e475c664f7b2685231d9e9"
|
||||
integrity sha1-ritPTFxxmgP55HXGZPeyaFIx2ek=
|
||||
|
||||
markdown-it-plantuml@^1.4.1:
|
||||
version "1.4.1"
|
||||
resolved "https://registry.yarnpkg.com/markdown-it-plantuml/-/markdown-it-plantuml-1.4.1.tgz#3bd5e7d92eaa5c6c68eb29802f7b46a8e05ca998"
|
||||
integrity sha512-13KgnZaGYTHBp4iUmGofzZSBz+Zj6cyqfR0SXUIc9wgWTto5Xhn7NjaXYxY0z7uBeTUMlc9LMQq5uP4OM5xCHg==
|
||||
|
||||
markdown-it-regexp@~0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/markdown-it-regexp/-/markdown-it-regexp-0.4.0.tgz#d64d713eecec55ce4cfdeb321750ecc099e2c2dc"
|
||||
@ -9113,6 +9108,11 @@ packet-reader@0.2.0:
|
||||
resolved "https://registry.yarnpkg.com/packet-reader/-/packet-reader-0.2.0.tgz#819df4d010b82d5ea5671f8a1a3acf039bcd7700"
|
||||
integrity sha1-gZ300BC4LV6lZx+KGjrPA5vNdwA=
|
||||
|
||||
pako@1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.3.tgz#5f515b0c6722e1982920ae8005eacb0b7ca73ccf"
|
||||
integrity sha1-X1FbDGci4ZgpIK6ABerLC3ynPM8=
|
||||
|
||||
pako@~1.0.5:
|
||||
version "1.0.10"
|
||||
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.10.tgz#4328badb5086a426aa90f541977d4955da5c9732"
|
||||
@ -9630,6 +9630,14 @@ pkginfo@^0.2.3:
|
||||
resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.2.3.tgz#7239c42a5ef6c30b8f328439d9b9ff71042490f8"
|
||||
integrity sha1-cjnEKl72wwuPMoQ52bn/cQQkkPg=
|
||||
|
||||
plantuml-encoder@^1.2.5:
|
||||
version "1.2.5"
|
||||
resolved "https://registry.yarnpkg.com/plantuml-encoder/-/plantuml-encoder-1.2.5.tgz#6b8e5b9e1a1dbd88b3fd9fb46f734eec7d44b548"
|
||||
integrity sha512-viV7Sz+BJNX/sC3iyebh2VfLyAZKuu3+JuBs2ISms8+zoTGwPqwk3/WEDw/zROmGAJ/xD4sNd8zsBw/YmTo7ng==
|
||||
dependencies:
|
||||
pako "1.0.3"
|
||||
utf8-bytes "0.0.1"
|
||||
|
||||
platform@1.3.5:
|
||||
version "1.3.5"
|
||||
resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.5.tgz#fb6958c696e07e2918d2eeda0f0bc9448d733444"
|
||||
@ -12791,6 +12799,11 @@ utf-8-validate@~5.0.1:
|
||||
dependencies:
|
||||
node-gyp-build "~3.7.0"
|
||||
|
||||
utf8-bytes@0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/utf8-bytes/-/utf8-bytes-0.0.1.tgz#116b025448c9b500081cdfbf1f4d6c6c37d8837d"
|
||||
integrity sha1-EWsCVEjJtQAIHN+/H01sbDfYg30=
|
||||
|
||||
util-deprecate@^1.0.1, util-deprecate@~1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
|
||||
|
Loading…
x
Reference in New Issue
Block a user