Skip to content

Instantly share code, notes, and snippets.

@wzulfikar
Last active October 20, 2022 07:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save wzulfikar/df4a83eba6910e2d804e2f69c5804938 to your computer and use it in GitHub Desktop.
Save wzulfikar/df4a83eba6910e2d804e2f69c5804938 to your computer and use it in GitHub Desktop.
MacDown template that support mermaid diagram (http://knsv.github.io/mermaid/index.html). Save this snippet as `Default.handlebars` in `/Applications/MacDown.app/Contents/Resources/Templates/`
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
{{{ titleTag }}}
{{#each styleTags }}
{{{ this }}}
{{/each }}
<!-- link to mermaid css -->
<link rel="stylesheet" type="text/css" href="/Volumes/data/archive/tools/mermaid-macdown/mermaid.css">
</head>
<body>
{{{ body }}}
{{#each scriptTags }}
{{{ this }}}
{{/each }}
<!-- link to mermaid js -->
<script src="/Volumes/data/archive/tools/mermaid-macdown/mermaid.min.js"></script>
<script>
!function(){
var uml,containerElement,
umlElement=document.querySelector(".language-mermaid-uml");
while(umlElement){
uml=umlElement.innerHTML;
containerElement = umlElement.parentNode.parentNode;
containerElement.className = "mermaid";
containerElement.innerHTML=uml;
umlElement=document.querySelector(".language-mermaid-uml");
}
}();
mermaid.initialize({startOnLoad:true});
/**
* use `mermaid-uml` as codeblock language.
* eg:
* ```mermaid-uml
* graph TD;
* A-->B;
* A-->C;
* B-->D;
* C-->D;
* ```
*
* ```mermaid-uml
* sequenceDiagram
* participant Alice
* Alice->John: Hello John, how are you?
* ```
*/
</script>
</body>
</html>
@chsWeb
Copy link

chsWeb commented Mar 4, 2019

I followed the directions above, but when I attempt to create a mermaid diagram in MacDown, it does not work.

MacDown Version 0.7.2d49 (919)
Mac OS High Sierra 10.13.6

Is this still supported?

@yemM
Copy link

yemM commented May 27, 2021

Works like a charm thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment