Edo*_*iel 27
可以使用每个图的指令更改 Markdown 文档中的主题。
这是一个示例(使用 Material for Mkdocs 进行测试):
This graph uses the forest theme:
``` mermaid
%%{init: {'theme': 'forest', "flowchart" : { "curve" : "basis" } } }%%
graph LR
A[Foo] --> B[Bar]
B --> A
```
That one uses the neutral theme:
``` mermaid
%%{init: {'theme': 'neutral' } }%%
graph LR
A[Foo] --> B[Bar]
B --> C[Baz]
```
Run Code Online (Sandbox Code Playgroud)
结果将是:
我一直在寻找与您相同的东西,因此在查看并深入研究美人鱼源代码后,可以找到以下代码片段:
for (const themeName of ['default', 'forest', 'dark', 'neutral']) {
themes[themeName] = require(`./themes/${themeName}/index.scss`)
}
Run Code Online (Sandbox Code Playgroud)
因此,在他们的编辑器中进行测试之后,这些主题运行良好:
如果要构建自定义主题,可以在这里找到它们的主题:https : //github.com/knsv/mermaid/tree/master/src/themes
如果您转到Mermaid在线编辑器,则可以将主题更改为上述主题:
小智 5
据我所知,设置主题的唯一机会是初始化:
mermaid.initialize({
theme: 'forest',
logLevel: 1,
flowchart: { curve: 'linear' },
});
Run Code Online (Sandbox Code Playgroud)