Skip to content

Commit

Permalink
add support for --theme
Browse files Browse the repository at this point in the history
  • Loading branch information
raghur committed Nov 10, 2017
1 parent b7e7f78 commit 04b6df8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ You have a couple of formatting options via attributes of the fenced code block

- Image Format - Use `{.mermaid format=svg}` Default is png
- Width - Use `{.mermaid width=400}` default with is 500
- Theme - Use `{.mermaid theme=forest}` default is 'default'. Corresponds to `--theme` flag of mermaid.cli
- Save path - Use `{.mermaid loc=img}` default loc=inline which will
encode the image in a `data uri` scheme.
- Possible values for `loc`
Expand All @@ -49,3 +50,10 @@ You have a couple of formatting options via attributes of the fenced code block

Note that to specify options, you need to use the curly braces syntax and have the `.mermaid` class attached.
Admittedly, this is uglier than the earlier syntax on top - but that's how Pandoc wants it.

JSON and CSS configuration
---------------------------

Mermaid cli allows you to specify additional options in a json configuration file and a css file. `mermaid-filter`
will look in the current directory for `.mermaid-config.json` and `.mermaid.css` and if found, pass them in to
mermaid cli.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function mermaid(type, value, format, meta) {
var attrs = value[0],
content = value[1];
var classes = attrs[1];
var options = {width: '500', format: 'png', loc: 'inline'};
var options = {width: '500', format: 'png', loc: 'inline', theme: "default"};
var configFile = path.join(folder, ".mermaid-config.json")
var confFileOpts = ""
if (fs.existsSync(configFile)) {
Expand Down Expand Up @@ -48,7 +48,7 @@ function mermaid(type, value, format, meta) {
// console.log(outdir);
var savePath = tmpfileObj.name + "." + options.format
var newPath = path.join(outdir, `${prefix}-${counter}.${options.format}`);
var fullCmd = `${cmd} ${confFileOpts} -w ${options.width} -i ${tmpfileObj.name} -o ${savePath}`
var fullCmd = `${cmd} ${confFileOpts} -w ${options.width} -i ${tmpfileObj.name} -t ${options.theme} -o ${savePath}`
// console.log(fullCmd, savePath)
exec(fullCmd);
//console.log(oldPath, newPath);
Expand Down
10 changes: 10 additions & 0 deletions test.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,13 @@ sequenceDiagram
Alice->>John: Hello John, how are you?
John-->>Alice: Great!
```

With theme specified
---------------------

```{.mermaid width=100 format=svg theme=forest}
sequenceDiagram
Alice->>John: Hello John, how are you?
John-->>Alice: Great!
```

0 comments on commit 04b6df8

Please sign in to comment.