Skip to content

Commit cc2a428

Browse files
committed
Try to fix mermaid parse issue
1 parent 32bc2e0 commit cc2a428

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "markdown-it-mermaid",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"description": "Mermaid plugin for markdown-it.",
55
"main": "src/index.js",
66
"scripts": {

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const mermaidChart = (code) => {
66
window.mermaid.parseError = (error, hash) => {
77
mermaidError = error
88
}
9-
if (window.mermaid.parse(code)) {
9+
if (window.mermaid.parse(code) || mermaidError === null) {
1010
return `<div class="mermaid">${code}</div>`
1111
} else {
1212
return `<pre>${mermaidError}</pre>`
@@ -31,7 +31,7 @@ const MermaidPlugin = (md) => {
3131
const temp = md.renderer.rules.fence.bind(md.renderer.rules)
3232
md.renderer.rules.fence = (tokens, idx, options, env, slf) => {
3333
const token = tokens[idx]
34-
const code = token.content.trim() + '\n' // git graph requires line break at the end
34+
const code = token.content.trim()
3535
if (token.info === 'mermaid') {
3636
return mermaidChart(code)
3737
}

0 commit comments

Comments
 (0)