-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
293 lines (264 loc) · 25.5 KB
/
index.html
File metadata and controls
293 lines (264 loc) · 25.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="MarkBind 6.3.1">
<meta name="viewport" content="width=device-width, initial-scale=1"><title>MarkBind - Generate More Dynamic Websites from Markdown Text</title> <link rel="stylesheet" href="/markbind/css/bootstrap.min.css"> <link rel="stylesheet" href="/markbind/fontawesome/css/all.min.css"> <link rel="stylesheet" href="/markbind/glyphicons/css/bootstrap-glyphicons.min.css"><link rel="stylesheet" href="/markbind/css/codeblock-light.min.css"><link rel="stylesheet" href="/markbind/css/markbind.min.css"><link rel="stylesheet" href="/plugins/codeBlockWrapButtons/codeBlockButtons.css"><link rel="stylesheet" href="/plugins/web3Form/web-3-form.css"><link rel="stylesheet" href="/plugins/codeBlockCopyButtons/codeBlockButtons.css"><link rel="stylesheet" href="/plugins/dataTable/datatables.min.css"><link rel="stylesheet" href="/plugins/dataTable/datatables-additional.css"><link rel="stylesheet" href="/plugins/markbind-plugin-anchors/markbind-plugin-anchors.css"><link rel="stylesheet" href="/plugins/markbind-plugin-tree/markbind-plugin-tree.css">
<link rel="stylesheet" href="/css/main.css">
<link rel="icon" href="/favicon.ico"></head>
<script>
const baseUrl = ''
</script>
<body data-code-theme="light">
<div id="app"><!--[--><header sticky><div data-v-26aac3dc><nav class="navbar navbar-expand-md d-print-none navbar-dark bg-dark" data-v-26aac3dc><div class="container-fluid" data-v-26aac3dc><div class="navbar-left" data-v-26aac3dc><!--[--><a href="/index.html" title="Home" class="navbar-brand"><img src="/images/logo-darkbackground.svg" height="20"></a><!--]--></div><div class="navbar-default" data-v-26aac3dc><ul class="navbar-nav me-auto mt-2 mt-lg-0" data-v-26aac3dc><!--[--> <li><a highlight-on="exact" href="/index.html" class="nav-link">HOME</a></li> <div tags="environment--ug environment--combined"><li><a highlight-on="sibling-or-child" href="/userGuide/index.html" class="nav-link">USER GUIDE</a></li></div> <li><a highlight-on="exact" href="/showcase.html" class="nav-link">SHOWCASE</a></li> <li><a highlight-on="exact" href="/about.html" class="nav-link">ABOUT</a></li> <li><a href="https://github.com/MarkBind/markbind" target="_blank" class="nav-link"><span><span aria-hidden="true" class="fab fa-github"></span></span></a></li> <!--]--></ul></div><ul class="navbar-nav navbar-right" data-v-26aac3dc><!--[--><li><form class="navbar-form"><div style="position:relative;" class="dropdown" data-v-00e26d0a><!--[--><input value="" data-bs-toggle="dropdown" type="text" class="form-control" placeholder="Search" autocomplete="off" data-v-00e26d0a><div class="form-control placeholder-div-hidden" data-v-00e26d0a>Search</div><!--]--><ul class="dropdown-menu search-dropdown-menu dropdown-menu-hidden dropdown-menu-end" data-v-00e26d0a><!--[--><!--]--></ul></div></form></li><!--]--></ul></div></nav><div style="display:none;" class="lower-navbar-container" data-v-26aac3dc><!--[--><!----><!----><!--]--></div></div></header> <div id="flex-body"><div id="content-wrapper"><div tags="environment--ug environment--combined"><h1 class="display-3" id="markbind"><span><strong>MarkBind</strong></span><a class="fa fa-anchor" href="#markbind" onclick="event.stopPropagation()"></a></h1> <div class="lead"><p><span class="large"><strong>Generate <span class="trigger" data-mb-component-type="tooltip" tabindex="0"><!----><!-- do not delete this comment, it is for the stray space issue (#2419)
--><!----></span> websites from Markdown text.</strong></span>
Optimized for creating text-heavy websites <span class="dimmed">e.g., eLearning websites, online instruction manuals, project documentation etc.</span></p></div> <p><a class="btn btn-primary" href="/userGuide">Get Started</a></p> <hr> <h4 id="simple-syntax-dynamic-content"><span style="color:#00B0F0;"><span aria-hidden="true" class="fas fa-check-circle"></span></span> Simple syntax. Dynamic content.<a class="fa fa-anchor" href="#simple-syntax-dynamic-content" onclick="event.stopPropagation()"></a></h4> <p>MarkBind source files can be as simple as basic Markdown, but you can also <a href="/userGuide/markBindSyntaxOverview.html"><strong>use a mix of several popular syntax schemes</strong></a> (<span class="trigger" data-mb-component-type="tooltip" tabindex="0"><!----><!-- do not delete this comment, it is for the stray space issue (#2419)
--><!----></span>, Bootstrap, Nunjucks, etc. as well as MarkBind's own custom syntax) to create more dynamic content that you cannot normally get from a typical markdown-to-html site generator.</p> <p>Here are some simple text-formatting examples:</p> <div class="table-responsive"><table class="markbind-table table table-bordered table-striped"><thead><tr><th>Syntax scheme</th> <th>Code</th> <th>Output</th></tr></thead> <tbody><tr><td>Markdown</td> <td><code class="hljs inline no-lang">**bold text** _italic text_</code></td> <td><strong>bold text</strong> <em>italic text</em></td></tr> <tr><td>GFMD</td> <td><code class="hljs inline no-lang">~~striked out text~~</code></td> <td><s>striked out text</s></td></tr> <tr><td>MarkBind extensions to Markdown</td> <td><code class="hljs inline no-lang">==highlighted text==</code><br><code class="hljs inline no-lang">%%grey text%%</code><br><code class="hljs inline no-lang">!!underlined text!!</code></td> <td><mark>highlighted text</mark><br><span class="dimmed">grey text</span><br><span class="underline">underlined text</span></td></tr></tbody></table></div><div class="card-container" data-v-4484e25a><div class="card expandable-card card-seamless border-0" data-v-4484e25a><div class="card-header header-toggle bg-transparent border-0" data-v-4484e25a><div class="caret-wrapper" data-v-4484e25a><span class="glyphicon glyphicon-chevron-right" data-v-4484e25a></span></div><div class="header-wrapper-seamless header-wrapper card-title bg-transparent" data-v-4484e25a><!--[--><!--[--><p><span class="dimmed">More examples of generating static content</span></p><!--]--><!--]--></div><div class="button-wrapper" data-v-4484e25a><!--[--><button type="button" class="collapse-button btn btn-outline-light" style="display:none;" data-v-4484e25a><span class="collapse-icon glyphicon glyphicon-menu-down" aria-hidden="true"></span></button><button style="" type="button" class="btn-outline-light seamless-button close-button btn" data-v-4484e25a><span class="glyphicon glyphicon-remove" aria-hidden="true" data-v-4484e25a></span></button><button style="display:none;" type="button" class="btn-outline-light seamless-button popup-button btn" data-v-4484e25a><span class="glyphicon glyphicon-new-window" aria-hidden="true" data-v-4484e25a></span></button><!--]--></div></div><div class="card-collapse" data-v-4484e25a><!----><hr style="" data-v-4484e25a></div><!----></div></div> <p></p> <p>The example paragraph below has the following dynamic elements: a tooltip, a popover, and a modal. Hover/click on the underlined words to see each.</p> <div class="alert box-container alert-default" style="" data-v-19514615><!--Icon and vertical divider for seamless header box--><!----><div class="header-and-body" data-v-19514615><!-- Header wrapper, not rendered if there is no header attribute --><!----><!-- Body wrapper --><div class="box-body-wrapper" data-v-19514615><!-- icon on the left, not shown if there is a header --><!----><!-- Icon -- content divider for seamless boxes without the header attribute --><!----><!-- Content wrapper --><div class="contents" style="" data-v-19514615><!--[--><p>In <span class="trigger" data-mb-component-type="tooltip" tabindex="0"><!----><!-- do not delete this comment, it is for the stray space issue (#2419)
--><!----></span>, a binary tree is a <span class="trigger" tabindex="0"><span><!--[-->tree data structure<!--]--></span></span> in which each node has at most two children, which are referred to as the <em>left child</em> and the <em>right child</em>. <span class="trigger-click" tabindex="0"><span><!--[-->Primitive data types<!--]--></span></span> on the other hand ...</p> <span class="trigger" data-mb-component-type="popover" tabindex="0" id="pop:index-tree"><!----><!-- do not delete this comment, it is for the stray space issue (#2419)
--><!----></span> <!--[--><!-- NavBar has z-index of 1000, hence the z-index here should exceed that --><!-- SSR property is required for the snapshot tests to work --><!----><!--]--><!--]--></div><!-- dismiss button on the right, not shown if there is a header --><!----></div></div></div> <div class="card-container" data-v-4484e25a><div class="card expandable-card card-seamless border-0" data-v-4484e25a><div class="card-header header-toggle bg-transparent border-0" data-v-4484e25a><div class="caret-wrapper" data-v-4484e25a><span class="glyphicon glyphicon-chevron-right" data-v-4484e25a></span></div><div class="header-wrapper-seamless header-wrapper card-title bg-transparent" data-v-4484e25a><!--[--><!--[--><p><span class="dimmed">More examples of generating dynamic content</span></p><!--]--><!--]--></div><div class="button-wrapper" data-v-4484e25a><!--[--><button type="button" class="collapse-button btn btn-outline-light" style="display:none;" data-v-4484e25a><span class="collapse-icon glyphicon glyphicon-menu-down" aria-hidden="true"></span></button><button style="" type="button" class="btn-outline-light seamless-button close-button btn" data-v-4484e25a><span class="glyphicon glyphicon-remove" aria-hidden="true" data-v-4484e25a></span></button><button style="display:none;" type="button" class="btn-outline-light seamless-button popup-button btn" data-v-4484e25a><span class="glyphicon glyphicon-new-window" aria-hidden="true" data-v-4484e25a></span></button><!--]--></div></div><div class="card-collapse" data-v-4484e25a><!----><hr style="" data-v-4484e25a></div><!----></div></div> <p></p> <hr> <h4 id="everything-you-need-for-text-heavy-websites-built-in"><span style="color:#00B0F0;"><span aria-hidden="true" class="fas fa-check-circle"></span></span> Everything you need for text-heavy websites, built-in.<a class="fa fa-anchor" href="#everything-you-need-for-text-heavy-websites-built-in" onclick="event.stopPropagation()"></a></h4> <p>MarkBind is <strong>highly optimized for creating text-heavy websites</strong> <span class="dimmed">e.g., eLearning websites, online instruction manuals, project documentation etc.</span> Anything that you might need for creating such websites are built-in, sparing you the hassle of finding/installing/searching plugins that you need.</p> <p>Here are some examples:</p> <div class="indented"><p><span class="large"><span aria-hidden="true" class="fas fa-heart"></span></span> <strong>Icons</strong> can improve the readability of a text-heavy document. MarkBind comes with a wide selection of <a href="/userGuide/formattingContents.html#icons">icons</a> and <a href="/userGuide/formattingContents.html#emoji">emoji</a>.<br> <span class="large"><span aria-hidden="true" class="fas fa-search"></span></span> With MarkBind's <a href="/userGuide/makingTheSiteSearchable.html"><strong>search feature</strong></a>, you can allow readers to search for keywords in your site.<br> <span class="large"><span aria-hidden="true" class="fas fa-window-maximize"></span></span> MarkBind allows you to add <a href="/userGuide/tweakingThePageStructure.html"><strong>site/page navigation menus, headers, footers</strong></a> easily.</p></div> <hr> <h4 id="more-control-to-the-reader-without-duplicating-code"><span style="color:#00B0F0;"><span aria-hidden="true" class="fas fa-check-circle"></span></span> More control to the reader, without duplicating code.<a class="fa fa-anchor" href="#more-control-to-the-reader-without-duplicating-code" onclick="event.stopPropagation()"></a></h4> <p>A MarkBind website can be a <em>buffet</em> of content, as opposed to a <em>set menu</em>: a site can have optional contents that the reader can access at her discretion, and the same content can be organized in multiple ways so that the reader can choose the one that fits the need. To <em>cater</em> (pun intended) for creating such buffet style websites, MarkBind has <strong><a href="/userGuide/reusingContents.html">reuse mechanisms</a> for presenting the same content in multiple ways without duplicating the source file</strong>.</p> <p>For example, MarkBind has a powerful <code class="hljs inline no-lang">include</code> mechanism that allows content fragments (i.e., a file or part of a file) to be reused at multiple places in the website. In the example below, both the modal and the expandable panel reuse the same content originating from a <em>single</em> source file.</p> <div class="alert box-container alert-default" style="" data-v-19514615><!--Icon and vertical divider for seamless header box--><!----><div class="header-and-body" data-v-19514615><!-- Header wrapper, not rendered if there is no header attribute --><!----><!-- Body wrapper --><div class="box-body-wrapper" data-v-19514615><!-- icon on the left, not shown if there is a header --><!----><!-- Icon -- content divider for seamless boxes without the header attribute --><!----><!-- Content wrapper --><div class="contents" style="" data-v-19514615><!--[--><p>In CS, a binary tree is a tree data structure in which each node has at most two children, which are referred to as the <em>left child</em> and the <em>right child</em>. <span class="trigger-click" tabindex="0"><span><!--[-->Primitive data types<!--]--></span></span> on the other hand ...</p> <div class="card-container" data-v-4484e25a><div class="card expandable-card card-seamless border-0" data-v-4484e25a><div class="card-header header-toggle bg-transparent border-0" data-v-4484e25a><div class="caret-wrapper" data-v-4484e25a><span class="glyphicon glyphicon-chevron-right" data-v-4484e25a></span></div><div class="header-wrapper-seamless header-wrapper card-title bg-transparent" data-v-4484e25a><!--[--><!--[--><p><span class="dimmed"><span aria-hidden="true" class="fas fa-info-circle"></span> Some example primitive data types</span></p><!--]--><!--]--></div><div class="button-wrapper" data-v-4484e25a><!--[--><button type="button" class="collapse-button btn btn-outline-light" style="display:none;" data-v-4484e25a><span class="collapse-icon glyphicon glyphicon-menu-down" aria-hidden="true"></span></button><button style="" type="button" class="btn-outline-light seamless-button close-button btn" data-v-4484e25a><span class="glyphicon glyphicon-remove" aria-hidden="true" data-v-4484e25a></span></button><button style="display:none;" type="button" class="btn-outline-light seamless-button popup-button btn" data-v-4484e25a><span class="glyphicon glyphicon-new-window" aria-hidden="true" data-v-4484e25a></span></button><!--]--></div></div><div class="card-collapse" data-v-4484e25a><!----><hr style="" data-v-4484e25a></div><!----></div></div> <!--[--><!-- NavBar has z-index of 1000, hence the z-index here should exceed that --><!-- SSR property is required for the snapshot tests to work --><!----><!--]--><!--]--></div><!-- dismiss button on the right, not shown if there is a header --><!----></div></div></div> <hr> <h4 id="easy-to-set-up-modify-deploy-integrate"><span style="color:#00B0F0;"><span aria-hidden="true" class="fas fa-check-circle"></span></span> Easy to set up, modify, deploy, integrate.<a class="fa fa-anchor" href="#easy-to-set-up-modify-deploy-integrate" onclick="event.stopPropagation()"></a></h4> <p>Installing MarkBind takes just one command. Creating a new MarkBind site too takes just one command. With MarkBind's <em>live preview</em> feature, you can see how your site will look like as you modify the source file. <a href="/userGuide/deployingTheSite.html">Deploying the site to a server</a> can be as simple as one command too.</p> <p>As MarkBind is also optimized for project documentation, it can easily <a href="/userGuide/markBindInTheProjectWorkflow.html">integrate with the workflow of a software project</a>.</p> <p><a class="btn btn-primary" href="/userGuide">Get Started</a></p></div></div> <div class="scroll-top-button fa-lg d-print-none" style="display:none;bottom:2%;right:2%;position:fixed;" aria-hidden="true"><!--[--><i class="fas fa-arrow-circle-up"></i><!--]--></div></div> <div><footer><div class="text-center"><small>[Generated by <a href="https://markbind.org/">MarkBind 6.3.1</a> on Wed, 25 Feb 2026, 19:05:41 UTC]</small><br> <small>This site is powered by <a href="https://www.netlify.com/">Netlify</a>.</small></div></footer></div><!--]--></div>
</body><script src="/markbind/js/bootstrap-utility.min.js"></script>
<script src="/markbind/js/polyfill.min.js"></script>
<script src="/markbind/js/vue.global.prod.min.js"></script>
<script src="/markbind/js/markbind.min.js"></script>
<script src="index.page-vue-render.js"></script>
<script>
MarkBind.setupWithSearch()
</script>
<script>
function toggleCodeBlockWrap(element) {
const pre = element.parentElement.parentElement;
const tooltipText = element.querySelector(".tooltiptext");
const classList = pre.querySelector('code').classList;
if (classList.contains('wrap')) {
classList.remove('wrap');
tooltipText.innerText = `Wrap Text`;
} else {
classList.add('wrap')
tooltipText.innerText = `Unwrap Text`;
}
}
</script>
<script>
function submitForm(element) {
event.preventDefault();
const formData = new FormData(element);
const formProps = Object.fromEntries(formData);
const json = JSON.stringify(formProps);
const submitButton = element.querySelector('button[type="submit"]');
const submitButtonText = submitButton.innerText;
submitButton.innerText = 'Please wait...'
fetch('https://api.web3forms.com/submit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: json,
})
.then(async (response) => {
if (response.status == 200) {
alert('Form submitted! Thank you for your response');
} else {
alert('Error submitting form! Please try again later.');
}
})
.catch(error => {
alert('Error submitting form! Please try again later.');
})
.finally(() => {
submitButton.innerText = submitButtonText;
})
}
</script>
<script>
function copyCodeBlock(element) {
const pre = element.parentElement.parentElement;
const codeElement = pre.querySelector('code');
const copyButtonBody = element.querySelector('.function-btn-body');
const tooltipText = element.querySelector(".tooltiptext");
// create dummy text element to select() the text field
const textElement = document.createElement('textarea');
textElement.value = codeElement.textContent;
document.body.appendChild(textElement);
textElement.select();
document.execCommand('copy');
document.body.removeChild(textElement);
copyButtonBody.innerHTML = `
<svg
xmlns="http://www.w3.org/2000/svg"
width="18"
height="18"
viewBox="2 2 22 22"
>
<path d="M 19.28125 5.28125 L 9 15.5625 L 4.71875 11.28125 L 3.28125 12.71875 L 8.28125 17.71875
L 9 18.40625 L 9.71875 17.71875 L 20.71875 6.71875 Z"></path>
</svg>
`;
console.log("Running tooltip");
tooltipText.innerText = `Copied!`;
setTimeout(() => {
copyButtonBody.innerHTML = `
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="18" height="18" viewBox="0 0 18 18" version="1.1">
<g id="surface1">
<path d="M 11.273438 0 L 2.546875 0 C 1.746094 0 1.089844 0.613281 1.089844
1.363281 L 1.089844 10.910156 L 2.546875 10.910156 L 2.546875 1.363281 L 11.273438
1.363281 Z M 13.453125 2.726562 L 5.453125 2.726562 C 4.65625 2.726562 4 3.339844 4
4.089844 L 4 13.636719 C 4 14.386719 4.65625 15 5.453125 15 L 13.453125 15 C 14.253906
15 14.910156 14.386719 14.910156 13.636719 L 14.910156 4.089844 C 14.910156 3.339844
14.253906 2.726562 13.453125 2.726562 Z M 13.453125 13.636719 L 5.453125 13.636719 L
5.453125 4.089844 L 13.453125 4.089844 Z M 13.453125 13.636719 "/>
</g>
</svg>
`;
tooltipText.innerText = `Copy`;
}, 3000);
}
</script>
<script src="/plugins/dataTable/datatables.min.js"></script>
<script>
function getTableOptions(el) {
const options = {};
if ($(el).hasClass('sortable-table')) {
options.searching = false;
options.paging = false;
options.info = false;
} else if ($(el).hasClass('searchable-table')) {
options.ordering = false;
options.paging = false;
options.info = false;
options.dom = '<"row"<"col-sm-12"f>>' + '<"row"<"col-sm-12"t>>';
} else if ($(el).hasClass('sortable-searchable-table')) {
options.paging = false;
options.info = false;
options.dom = '<"row"<"col-sm-12"f>>' + '<"row"<"col-sm-12"t>>';
}
return options;
}
function initializeTables(tables) {
if (!tables || tables.length === 0) return;
tables.forEach(table => {
const options = getTableOptions(table);
$(table).DataTable(options);
$(table).addClass('dt-processed');
});
}
function setupTableObserver() {
const observer = new MutationObserver((mutations) => {
let newTables = [];
mutations.forEach(mutation => {
if (mutation.addedNodes.length) {
mutation.addedNodes.forEach(node => {
if (node.nodeType === 1 && node.tagName === 'TABLE' &&
!$(node).hasClass('dt-processed') &&
($(node).hasClass('sortable-table') ||
$(node).hasClass('searchable-table') ||
$(node).hasClass('sortable-searchable-table'))) {
newTables.push(node);
}
if (node.nodeType === 1 && node.querySelectorAll) {
const tablesInNode = node.querySelectorAll(
'table.sortable-table:not(.dt-processed), ' +
'table.searchable-table:not(.dt-processed), ' +
'table.sortable-searchable-table:not(.dt-processed)');
if (tablesInNode.length) {
newTables = [...newTables, ...tablesInNode];
}
}
});
}
});
if (newTables.length > 0) {
initializeTables(newTables);
}
});
// Start observing the entire document for changes
observer.observe(document.body, {
childList: true,
subtree: true
});
return observer;
}
document.addEventListener('DOMContentLoaded', function() {
// Process any existing tables
const existingTables = document.querySelectorAll(
'table.sortable-table:not(.dt-processed), ' +
'table.searchable-table:not(.dt-processed), ' +
'table.sortable-searchable-table:not(.dt-processed)'
);
if (existingTables.length > 0) {
initializeTables(existingTables);
}
setupTableObserver();
});
</script>
<script type="module">
window.mermaidPromise = null;
const loadMermaid = () => {
if (window.mermaidPromise === null) {
window.mermaidPromise = import('https://unpkg.com/mermaid@10/dist/mermaid.esm.min.mjs')
.then(({ default: mermaid }) => {
mermaid.initialize({
startOnLoad: false,
});
console.log('Mermaid loaded successfully');
return mermaid;
})
.catch((error) => {
console.error('Mermaid failed to load:', error);
window.mermaidPromise = false;
return null;
});
}
return window.mermaidPromise;
};
const renderMermaidDiagrams = (elements) => {
if (!elements || elements.length === 0) {
return Promise.resolve();
}
return loadMermaid().then(mermaid => {
if (!mermaid) return;
return mermaid.run({ nodes: Array.from(elements) })
.catch(err => console.error('Error rendering mermaid diagrams:', err));
});
};
const setupMermaidObserver = () => {
const observer = new MutationObserver((mutations) => {
let newMermaidElements = [];
mutations.forEach(mutation => {
if (mutation.addedNodes.length) {
mutation.addedNodes.forEach(node => {
if (node.nodeType === 1 && node.classList &&
node.classList.contains('mermaid')) {
newMermaidElements.push(node);
}
if (node.nodeType === 1 && node.querySelectorAll) {
const mermaidInNode = node.querySelectorAll('.mermaid');
if (mermaidInNode.length) {
newMermaidElements = [...newMermaidElements, ...mermaidInNode];
}
}
});
}
});
if (newMermaidElements.length > 0) {
renderMermaidDiagrams(newMermaidElements);
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
return observer;
};
// Initialize on DOM content loaded
document.addEventListener('DOMContentLoaded', () => {
const existingDiagrams = document.querySelectorAll('.mermaid');
if (existingDiagrams.length > 0) {
renderMermaidDiagrams(existingDiagrams);
}
setupMermaidObserver();
});
</script>
</html>