diff --git a/package.json b/package.json
index aa65e28..58417cb 100755
--- a/package.json
+++ b/package.json
@@ -642,6 +642,7 @@
"markdown-it": "^14.1.0",
"markdown-it-anchor": "^9.2.0",
"markdown-it-checkbox": "^1.1.0",
+ "markdown-it-mermaid": "^0.2.5",
"markdown-it-plantuml": "^1.4.1",
"markdown-it-toc-done-right": "^4.2.0",
"mustache": "^4.0.1",
diff --git a/src/service/markdown/markdown-pdf.js b/src/service/markdown/markdown-pdf.js
index c577bc1..db182a2 100644
--- a/src/service/markdown/markdown-pdf.js
+++ b/src/service/markdown/markdown-pdf.js
@@ -9,6 +9,7 @@ const markdownItPlantuml = require("markdown-it-plantuml")
const markdownItToc = require("markdown-it-toc-done-right")
const markdownItAnchor = require("markdown-it-anchor")
const { exportByType } = require('./html-export')
+const markdownItMermaid = require('markdown-it-mermaid').default;
async function convertMarkdown(inputMarkdownFile, config) {
@@ -17,8 +18,20 @@ async function convertMarkdown(inputMarkdownFile, config) {
const text = fs.readFileSync(inputMarkdownFile).toString()
const content = convertMarkdownToHtml(inputMarkdownFile, type, text, config)
const html = mergeHtml(content, uri)
- await exportByType(inputMarkdownFile, html, type, config)
+ // insert mermaid script
+ const $ = require("cheerio").load(html);
+ const containsMermaid = $('.mermaid').length > 0;
+ if (containsMermaid) {
+ const mermaidScript = `
+
+
+ `;
+
+ $('body').append(mermaidScript);
+ }
+
+ await exportByType(inputMarkdownFile, $.html(), type, config)
}
@@ -100,6 +113,7 @@ function convertMarkdownToHtml(filename, type, text, config) {
.use(markdownItToc)
.use(markdownItKatex)
.use(markdownItPlantuml)
+ .use(markdownItMermaid)
return md.render(text)