Skip to content

Instantly share code, notes, and snippets.

@calebklc
Last active March 8, 2019 03:02
Show Gist options
  • Save calebklc/6ade32ff2edc6f038dd653471d9be0ea to your computer and use it in GitHub Desktop.
Save calebklc/6ade32ff2edc6f038dd653471d9be0ea to your computer and use it in GitHub Desktop.
How to use mermaid in Total.js Wiki v2?

How to use mermaid in Total.js Wiki v2?

Usage

Basic Flowchart from https://mermaidjs.github.io/demos.html

```mermaid
graph LR
    A[Square Rect] -- Link text --> B((Circle))
    A --> C(Round Rect)
    B --> D{Rhombus}
    C --> D
```

Modification

  1. views/layout.html

Add scripts

<script src="https://unpkg.com/mermaid@7.1.2/dist/mermaid.js"></script>
<script>
  mermaid.mermaidAPI.initialize({ startOnLoad: true });
</script>
  1. public/js/ui.js

Create a function to render mermaid

function markdown_mermaid(selector) {
  mermaid.init(undefined, $(selector));
}

Call the function in refresh_markdown

function refresh_markdown(read) {
  var el = $(".markdown");
  if (el.length) {
    markdown_mermaid(".lang-mermaid");
    //...
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment