document.addEventListener('DOMContentLoaded', function() {
mermaid.initialize({
startOnLoad: true,
theme: 'default',
flowchart: {
useMaxWidth: true,
htmlLabels: true
}
});
const mermaidBlocks = document.querySelectorAll('pre code.language-mermaid, div[class*="mermaid"]');
mermaidBlocks.forEach((block, index) => {
try {
let code = block.textContent || block.innerText;
const newDiv = document.createElement('div');
newDiv.className = 'mermaid';
newDiv.id = 'mermaid-diagram-' + index;
newDiv.textContent = code;
block.parentNode.insertBefore(newDiv, block);
block.style.display = 'none';
} catch (error) {
console.error('Error rendering mermaid diagram:', error);
}
});
mermaid.run();
});