Skip to content

Commit 20c9dfe

Browse files
committed
- Add optional support for mermaid charts
1 parent 3f48ac8 commit 20c9dfe

15 files changed

Lines changed: 2107 additions & 24 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ $ alias madness='docker run --rm -it -v $PWD:/docs -p 3000:3000 dannyben/madness
5151
- Can optionally show additional file types in the navigation menu (e.g. PDF
5252
files).
5353
- Optional support for `[[Short Link]]` syntax.
54+
- Optional support for Mermaid diagrams.
5455
- Optional basic authentication.
5556
- Support for extended markdown syntax, such as footnotes and syntax
5657
highlighting.
@@ -153,6 +154,10 @@ auto_toc: true
153154
# enable syntax highlighter for code snippets
154155
highlighter: true
155156

157+
# enable mermaid diagramming and charting
158+
# put your diagram code inside <div class='mermaid'>...</div>
159+
mermaid: false
160+
156161
# enable the copy to clipboard icon for code snippets
157162
copy_code: true
158163

@@ -258,6 +263,11 @@ specifying internal links, where `[[Anything]]` will be converted to
258263
`[Anything](Anything)`, which will then be rendered as an internal link to a
259264
file or a directory in the same directory as the file itself.
260265

266+
### Mermaid Diagrams and Charts
267+
268+
When the `mermaid` option is enabled, you may display any mermaid diagram in
269+
your document by enclosing it in a `<div class='mermaid'>...</div>` block.
270+
261271
### Table of Contents Generation
262272

263273
#### Site-wide

app/public/js/vendor/mermaid.min.js

Lines changed: 2029 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/views/layout.slim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,10 @@ html
1717
script src="#{config.base_uri}/js/vendor/clipboard.min.js"
1818
script src="#{config.base_uri}/js/clipboard.js"
1919

20+
- if config.mermaid
21+
script src="#{config.base_uri}/js/vendor/mermaid.min.js"
22+
javascript:
23+
mermaid.initialize({startOnLoad:true});
24+
2025
body
2126
== yield

lib/madness/rendering/pandoc.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Pandoc
66
include ServerHelper
77

88
def render(text)
9-
PandocRuby.new(text, [{ from: :markdown, to: :html }], *options).convert
9+
PandocRuby.new(text, [{ from: :gfm, to: :html }], *options).convert
1010
end
1111

1212
private

lib/madness/settings.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def defaults
6464
auto_nav: true,
6565
auto_toc: true,
6666
highlighter: true,
67+
mermaid: false,
6768
copy_code: true,
6869
shortlinks: false,
6970
source_link: nil,

lib/madness/templates/madness.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ auto_toc: true
4242
# enable syntax highlighter for code snippets
4343
highlighter: true
4444

45+
# enable mermaid diagramming and charting
46+
# put your diagram code inside <div class='mermaid'>...</div>
47+
mermaid: false
48+
4549
# enable the copy to clipboard icon for code snippets
4650
copy_code: true
4751

site/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ <h2 id="table-of-contents">Table of Contents</h2>
3737
<li><a href="#images-and-static-files">Images and Static Files</a></li>
3838
<li><a href="#automatic-h1">Automatic H1</a></li>
3939
<li><a href="#shortlinks">Shortlinks</a></li>
40+
<li><a href="#mermaid-diagrams-and-charts">Mermaid Diagrams and Charts</a></li>
4041
<li><a href="#table-of-contents-generation">Table of Contents Generation</a></li>
4142
<li><a href="#hidden-directories">Hidden Directories</a></li>
4243
<li><a href="#controlling-sort-order">Controlling Sort Order</a></li>
@@ -82,6 +83,7 @@ <h2 id="feature-highlights">Feature Highlights</h2>
8283
<li>Can optionally show additional file types in the navigation menu (e.g. PDF
8384
files).</li>
8485
<li>Optional support for <code>[[Short Link]]</code> syntax.</li>
86+
<li>Optional support for Mermaid diagrams.</li>
8587
<li>Optional basic authentication.</li>
8688
<li>Support for extended markdown syntax, such as footnotes and syntax
8789
highlighting.</li>
@@ -171,6 +173,10 @@ <h2 id="configuration-file">Configuration File</h2>
171173
<span class="c1"># enable syntax highlighter for code snippets</span>
172174
<span class="na">highlighter</span><span class="pi">:</span> <span class="kc">true</span>
173175

176+
<span class="c1"># enable mermaid diagramming and charting</span>
177+
<span class="c1"># put your diagram code inside &lt;div class='mermaid'&gt;...&lt;/div&gt;</span>
178+
<span class="na">mermaid</span><span class="pi">:</span> <span class="kc">false</span>
179+
174180
<span class="c1"># enable the copy to clipboard icon for code snippets</span>
175181
<span class="na">copy_code</span><span class="pi">:</span> <span class="kc">true</span>
176182

@@ -273,6 +279,11 @@ <h3 id="shortlinks">Shortlinks</h3>
273279
<code>[Anything](Anything)</code>, which will then be rendered as an internal link to a
274280
file or a directory in the same directory as the file itself.</p>
275281

282+
<h3 id="mermaid-diagrams-and-charts">Mermaid Diagrams and Charts</h3>
283+
284+
<p>When the <code>mermaid</code> option is enabled, you may display any mermaid diagram in
285+
your document by enclosing it in a <code>&lt;div class=&#39;mermaid&#39;&gt;...&lt;/div&gt;</code> block.</p>
286+
276287
<h3 id="table-of-contents-generation">Table of Contents Generation</h3>
277288

278289
<h4 id="site-wide">Site-wide</h4>

spec/approvals/cli/config/show

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
auto_nav: true
1010
auto_toc: true
1111
highlighter: true
12+
mermaid: ~
1213
copy_code: true
1314
shortlinks: ~
1415
source_link: ~

spec/approvals/cli/config/show-non-default

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
auto_nav: true
1010
auto_toc: true
1111
highlighter: true
12+
mermaid: ~
1213
copy_code: true
1314
shortlinks: ~
1415
source_link: ~

spec/approvals/cli/theme/theme-ls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- tmp/theme-test/public/js/vendor
1616
- tmp/theme-test/public/js/vendor/clipboard.min.js
1717
- tmp/theme-test/public/js/vendor/jquery.min.js
18+
- tmp/theme-test/public/js/vendor/mermaid.min.js
1819
- tmp/theme-test/styles
1920
- tmp/theme-test/styles/_anchor.scss
2021
- tmp/theme-test/styles/_breadcrumbs.scss

0 commit comments

Comments
 (0)