Skip to content

Commit 65ff7db

Browse files
committed
fix: Enhanced Mermaid code block detection for GitHub Pages
- Added fallback to detect mermaid syntax in all code blocks - Improved selector matching for Jekyll/Kramdown output - Better logging for debugging - Should now detect diagrams even if language class is missing
1 parent efe4748 commit 65ff7db

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

docs_site/_layouts/default.html

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,22 @@
799799
return;
800800
}
801801

802-
// Find all code blocks with mermaid language
803-
const mermaidBlocks = document.querySelectorAll('code.language-mermaid, pre code.language-mermaid, code[class*="mermaid"]');
802+
// Find all code blocks with mermaid language - try multiple selectors
803+
let mermaidBlocks = document.querySelectorAll('code.language-mermaid, pre code.language-mermaid, code[class*="mermaid"], pre code[class*="language-mermaid"]');
804+
805+
// If none found, check all code blocks for mermaid syntax
806+
if (mermaidBlocks.length === 0) {
807+
console.log('No mermaid language blocks found, checking all code blocks for mermaid syntax...');
808+
const allCodeBlocks = document.querySelectorAll('pre code');
809+
const foundBlocks = [];
810+
allCodeBlocks.forEach(block => {
811+
const code = block.textContent || block.innerText;
812+
if (code.trim().match(/^(graph|sequenceDiagram|flowchart|classDiagram|stateDiagram|erDiagram|gantt|pie|gitgraph|journey)/)) {
813+
foundBlocks.push(block);
814+
}
815+
});
816+
mermaidBlocks = foundBlocks;
817+
}
804818

805819
console.log('Found', mermaidBlocks.length, 'Mermaid code blocks');
806820

0 commit comments

Comments
 (0)