Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make puppeteer configurable #7

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 8 additions & 7 deletions README.md
Expand Up @@ -47,13 +47,14 @@ To generate:

## Options

| Name | Default | Description |
| --- | --- | --- |
| `language` | `"mermaid"` | Set this value to the identifier which will replace the code block. If you set it to `"graph"` then you can create graphs using ` ```graph ...`. |
| `theme` | `"default"` | Set this value to one of `"dark"`, `"neutral"`, `"forrest"`, or `"default"`. You can preview the themes in the [Live Editor](https://mermaidjs.github.io/mermaid-live-editor) |
| `viewport.width` | `200` | Set this value to the desired viewport width while rendering the svg |
| `viewport.height` | `200` | Set this value to the desired viewport height while rendering the svg |
| `mermaidOptions` | `{}` | This object specifies the [configuration options](https://mermaidjs.github.io/#/mermaidAPI) passed to `mermaid.initialize()` |
| Name | Default | Description |
| --- | --- | --- |
| `language` | `"mermaid"` | Set this value to the identifier which will replace the code block. If you set it to `"graph"` then you can create graphs using ` ```graph ...`. |
| `theme` | `"default"` | Set this value to one of `"dark"`, `"neutral"`, `"forrest"`, or `"default"`. You can preview the themes in the [Live Editor](https://mermaidjs.github.io/mermaid-live-editor) |
| `viewport.width` | `200` | Set this value to the desired viewport width while rendering the svg |
| `viewport.height` | `200` | Set this value to the desired viewport height while rendering the svg |
| `mermaidOptions` | `{}` | This object specifies the [configuration options](https://mermaidjs.github.io/#/mermaidAPI) passed to `mermaid.initialize()` |
| `puppeteerOptions` | `{args:['--no-sandbox', '--disable-setuid-sandbox']}` | Set this to override the default options passed to [`puppeteer.launch`](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions). |

### Defaults

Expand Down
5 changes: 3 additions & 2 deletions index.js
Expand Up @@ -40,7 +40,8 @@ module.exports = async ({markdownAST},
language = 'mermaid',
theme = 'default',
viewport = {height: 200, width: 200},
mermaidOptions = {}
mermaidOptions = {},
puppeteerOptions = {args:['--no-sandbox', '--disable-setuid-sandbox']}
}) => {

// Check if there is a match before launching anything
Expand All @@ -51,7 +52,7 @@ module.exports = async ({markdownAST},
}

// Launch virtual browser
const browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});
const browser = await puppeteer.launch(puppeteerOptions);

await Promise.all(nodes.map(async node => {
node.type = 'html';
Expand Down
4 changes: 4 additions & 0 deletions package.json
Expand Up @@ -7,6 +7,10 @@
"type": "git",
"url": "git+https://github.com/ChappIO/gatsby-remark-mermaid.git"
},
"files": [
"index.js",
"render.html"
],
"keywords": [
"gatsby",
"gatsby-plugin",
Expand Down