Skip to content

Instantly share code, notes, and snippets.

@Kremilly
Created May 7, 2024 15:46
Show Gist options
  • Save Kremilly/208f4f4e526ef89e101a49ec19cdf738 to your computer and use it in GitHub Desktop.
Save Kremilly/208f4f4e526ef89e101a49ec19cdf738 to your computer and use it in GitHub Desktop.
mermaid.initialize({
theme: 'dark',
securityLevel: 'loose',
})
let mermaidCodeBlocks = document.querySelectorAll('.language-mermaid')
mermaidCodeBlocks.forEach( block => {
block.classList.remove('language-mermaid')
block.classList.add('diagram-mermaid')
})
mermaidCodeBlocks.forEach( block => {
let diagramDiv = document.createElement('div')
diagramDiv.classList.add('mermaid')
diagramDiv.textContent = block.textContent
block.textContent = ''
block.appendChild(diagramDiv)
mermaid.init(undefined, diagramDiv)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment