Skip to content

Commit cb9764f

Browse files
committed
feat(config): allow pass through of puppeteer configuration
See #21
1 parent 6c7fb95 commit cb9764f

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,8 @@ JSON and CSS configuration
5656
---------------------------
5757

5858
Mermaid cli allows you to specify additional options in a json configuration file and a css file. `mermaid-filter`
59-
will look in the current directory for `.mermaid-config.json` and `.mermaid.css` and if found, pass them in to
59+
will look in the current working directory for `.mermaid-config.json` and `.mermaid.css` and if found, pass them in to
6060
mermaid cli.
61+
62+
Puppeteer Configuration - `mermaid-filter` will look in the current working directory for a `.puppeteer.json` and pass it
63+
on to mermaid cli (`-p` option of mmdc)if found

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ function mermaid(type, value, format, meta) {
2020
var classes = attrs[1];
2121
var options = {width: '500', format: 'png', loc: 'inline', theme: "default", caption: ""};
2222
var configFile = path.join(folder, ".mermaid-config.json")
23-
2423
var confFileOpts = ""
2524
if (fs.existsSync(configFile)) {
2625
confFileOpts += " -c " + configFile
2726
}
27+
var puppeteerConfig = path.join(folder, ".puppeteer.json")
28+
var puppeteerOpts = ""
29+
if (fs.existsSync(puppeteerConfig)) {
30+
puppeteerOpts += " -p " + puppeteerConfig
31+
}
2832
var cssFile = path.join(folder, ".mermaid.css")
2933
if (fs.existsSync(cssFile)) {
3034
confFileOpts += " -C " + cssFile
@@ -49,7 +53,7 @@ function mermaid(type, value, format, meta) {
4953
// console.log(outdir);
5054
var savePath = tmpfileObj.name + "." + options.format
5155
var newPath = path.join(outdir, `${prefix}-${counter}.${options.format}`);
52-
var fullCmd = `${cmd} ${confFileOpts} -w ${options.width} -i ${tmpfileObj.name} -t ${options.theme} -o ${savePath}`
56+
var fullCmd = `${cmd} ${confFileOpts} ${puppeteerOpts} -w ${options.width} -i ${tmpfileObj.name} -t ${options.theme} -o ${savePath}`
5357
// console.log(fullCmd, savePath)
5458
exec(fullCmd);
5559
//console.log(oldPath, newPath);

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mermaid-filter",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "Pandoc filter for mermaid",
55
"main": "index.js",
66
"scripts": {
@@ -20,8 +20,8 @@
2020
"dependencies": {
2121
"imgur": "^0.2.0",
2222
"lodash": "~3.10.1",
23-
"mermaid": "^7.1.0",
24-
"mermaid.cli": "^0.3.1",
23+
"mermaid": "^7.1.2",
24+
"mermaid.cli": "^0.4.6",
2525
"pandoc-filter": "^0.1.3",
2626
"tmp": "0.0.28"
2727
}

0 commit comments

Comments
 (0)