:lipstick:🚩 Add mermaid support. Close #56
This commit is contained in:
28
layouts/partials/_thirdparty/others/math.html
vendored
Normal file
28
layouts/partials/_thirdparty/others/math.html
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<!-- Load math render scripts -->
|
||||
{{ $math := .Params.math | default .Site.Params.math }}
|
||||
{{- partial "scripts/plugins.html" (dict "vendor" (.Scratch.Get "vendor") "router" (.Scratch.Get "router") "res" .Site.Data.resources.plugins "index" $math) }}
|
||||
{{ if eq $math "katex" }}
|
||||
<script type="text/javascript">
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
renderMathInElement(document.body, {
|
||||
delimiters: [
|
||||
{left: '$$', right: '$$', display: true},
|
||||
{left: '$', right: '$', display: false},
|
||||
{left: '\\(', right: '\\)', display: false},
|
||||
{left: '\\[', right: '\\]', display: true}
|
||||
],
|
||||
|
||||
throwOnError : false
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{{ end }}
|
||||
{{ if eq $math "mathjax" }}
|
||||
<script type="text/javascript">
|
||||
window.MathJax = {
|
||||
tex: {
|
||||
inlineMath: [["$", "$"]],
|
||||
}
|
||||
};
|
||||
</script>
|
||||
{{ end }}
|
||||
15
layouts/partials/_thirdparty/others/mermaid.html
vendored
Normal file
15
layouts/partials/_thirdparty/others/mermaid.html
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{{- partial "scripts/plugins.html" (dict "vendor" (.Scratch.Get "vendor") "router" (.Scratch.Get "router") "res" .Site.Data.resources.plugins "index" "mermaid") }}
|
||||
|
||||
<script type="text/javascript">
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
mermaid.initialize({
|
||||
sequence: {
|
||||
showSequenceNumbers: true,
|
||||
actorMargin: 50,
|
||||
diagramMarginX:10,
|
||||
diagramMarginY:10
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
{{ $vendor := .Site.Params.vendors.plugins }}
|
||||
{{ $router := index .Site.Data.resources.vendors $vendor }}
|
||||
{{ $globalVars.Set "vendor" $vendor }}
|
||||
{{ $globalVars.Set "router" $router }}
|
||||
|
||||
{{ $config := dict
|
||||
|
||||
@@ -1,39 +1,15 @@
|
||||
{{ partialCached "scripts/global.html" . }}
|
||||
|
||||
{{- $vendor := .Site.Params.vendors.plugins }}
|
||||
{{- $router := .Scratch.Get "router" }}
|
||||
{{ if or .Params.math .Site.Params.math }}
|
||||
{{ partialCached "_thirdparty/others/math.html" . }}
|
||||
{{ end }}
|
||||
|
||||
<!-- Load math render scripts -->
|
||||
{{ $math := .Params.math | default .Site.Params.math }}
|
||||
{{ if $math }}
|
||||
{{- partialCached "scripts/plugins.html" (dict "vendor" $vendor "router" $router "res" .Site.Data.resources.plugins "index" $math) }}
|
||||
{{ if eq $math "katex" }}
|
||||
<script type="text/javascript">
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
renderMathInElement(document.body, {
|
||||
delimiters: [
|
||||
{left: '$$', right: '$$', display: true},
|
||||
{left: '$', right: '$', display: false},
|
||||
{left: '\\(', right: '\\)', display: false},
|
||||
{left: '\\[', right: '\\]', display: true}
|
||||
],
|
||||
|
||||
throwOnError : false
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{{ end }}
|
||||
{{ if eq $math "mathjax" }}
|
||||
<script type="text/javascript">
|
||||
window.MathJax = {
|
||||
tex: {
|
||||
inlineMath: [["$", "$"]],
|
||||
}
|
||||
};
|
||||
</script>
|
||||
{{ end }}
|
||||
{{ if .Params.mermaid }}
|
||||
{{ partialCached "_thirdparty/others/mermaid.html" . }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
3
layouts/shortcodes/mermaid.html
Normal file
3
layouts/shortcodes/mermaid.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="mermaid" align="{{ .Get "align" | default "center" }}" {{ with .Get "bc" }} style="background: {{ . }}" {{ end }}>
|
||||
{{ safeHTML .Inner }}
|
||||
</div>
|
||||
Reference in New Issue
Block a user