diff --git a/_extensions/diagram/diagram.lua b/_extensions/diagram/diagram.lua index c2e8879..6ca4b0d 100644 --- a/_extensions/diagram/diagram.lua +++ b/_extensions/diagram/diagram.lua @@ -155,12 +155,27 @@ local mermaid = { return with_working_directory(tmpdir, function () local infile = 'diagram.mmd' local outfile = 'diagram.' .. file_extension + local args = {"--pdfFit", "--input", infile, "--output", outfile} + if self.opt then + if self.opt.theme then + table.insert(args, '--theme' .. stringify(self.opt.theme)) + table.insert(args, stringify(self.opt.cssFile)) + end + if self.opt.configFile then + table.insert(args, '--configFile') + table.insert(args, stringify(self.opt.configFile)) + end + if self.opt.cssFile then + table.insert(args, '--cssFile' .. stringify(self.opt.cssFile)) + table.insert(args, stringify(self.opt.cssFile)) + end + if self.opt.puppeteerConfigFile then + table.insert(args, '--puppeteerConfigFile') + table.insert(args, stringify(self.opt.puppeteerConfigFile)) + end + end write_file(infile, code) - pipe( - self.execpath or 'mmdc', - {"--pdfFit", "--input", infile, "--output", outfile}, - '' - ) + pipe(self.execpath or 'mmdc', args,'') return read_file(outfile), mime_type end) end) diff --git a/test/input-mermaid.md b/test/input-mermaid.md index c16c16d..073eef8 100644 --- a/test/input-mermaid.md +++ b/test/input-mermaid.md @@ -5,6 +5,19 @@ Mermaid is a JavaScript-based diagramming and charting tool. ``` mermaid %%| filename: flowchart %%| fig-cap: A simple flowchart. +%%{ + init: { + 'theme': 'base', + 'themeVariables': { + 'primaryColor': '#BB2528', + 'primaryTextColor': '#fff', + 'primaryBorderColor': '#7C0000', + 'lineColor': '#F8B229', + 'secondaryColor': '#006100', + 'tertiaryColor': '#fff' + } + } +}%% graph TD; A-->B; A-->C; diff --git a/test/test-mermaid.yaml b/test/test-mermaid.yaml index bc5d98f..e73427c 100644 --- a/test/test-mermaid.yaml +++ b/test/test-mermaid.yaml @@ -5,6 +5,10 @@ to: html metadata: pagetitle: Mermaid diagram diagram: - cache: false + engine: + mermaid: + execpath: /usr/local/bin/mmdc + puppeteerConfigFile: /etc/puppeteer-conf.json variables: document-css: false +embed-resources: true