fix: use parentElement and explicit mermaid.run() for reliable rendering
el.closest('pre') returns null after marp's polyfill replaces
<pre is="marp-pre"> with <marp-pre> on browsers without customized
built-in element support. el.parentElement works in both cases.
startOnLoad:true does not trigger in a deferred type="module" script
because DOMContentLoaded has already fired. Explicit mermaid.run()
ensures diagrams render regardless of timing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
afe0dff5f9
commit
695a8102e6
1 changed files with 3 additions and 2 deletions
|
|
@ -61,9 +61,10 @@ document.querySelectorAll('code.language-mermaid').forEach(el => {
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
div.className = 'mermaid';
|
div.className = 'mermaid';
|
||||||
div.textContent = el.textContent;
|
div.textContent = el.textContent;
|
||||||
el.closest('pre').replaceWith(div);
|
el.parentElement.replaceWith(div);
|
||||||
});
|
});
|
||||||
mermaid.initialize({ startOnLoad: true, theme: 'dark' });
|
mermaid.initialize({ startOnLoad: false, theme: 'dark' });
|
||||||
|
await mermaid.run();
|
||||||
</script>"""
|
</script>"""
|
||||||
|
|
||||||
with open(path, encoding='utf-8') as f:
|
with open(path, encoding='utf-8') as f:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue