|
8 | 8 |
|
9 | 9 | <!-- Marked.js for markdown parsing - try multiple CDNs for reliability --> |
10 | 10 | <script src="https://unpkg.com/marked/marked.min.js"></script> |
11 | | - <!-- Mermaid.js for diagram rendering --> |
12 | | - <script src=" https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js" ></script> |
| 11 | + <!-- Mermaid.js for diagram rendering - local fallback --> |
| 12 | + <script src="mermaid.min.js"></script> |
13 | 13 | <script> |
14 | 14 | // Fallback if marked.js fails to load |
15 | 15 | if (typeof marked === 'undefined') { |
|
411 | 411 | const codeBlocks = document.querySelectorAll('pre code'); |
412 | 412 |
|
413 | 413 | codeBlocks.forEach((codeBlock, index) => { |
414 | | - const text = codeBlock.textContent.trim(); |
| 414 | + let text = codeBlock.textContent.trim(); |
415 | 415 | const parentPre = codeBlock.parentElement; |
416 | 416 |
|
417 | 417 | // Check if this is a mermaid diagram - look for mermaid language or text starting with flowchart/graph/sequenceDiagram etc. |
|
429 | 429 | text.includes('subgraph'); |
430 | 430 |
|
431 | 431 | if (isMermaidLang || isMermaidContent) { |
| 432 | + // Clean up the text - remove "mermaid" prefix if it exists |
| 433 | + if (text.startsWith('mermaid\n') || text.startsWith('mermaid\r\n')) { |
| 434 | + text = text.substring(text.indexOf('\n') + 1).trim(); |
| 435 | + } else if (text.startsWith('mermaidflowchart')) { |
| 436 | + text = text.substring(7); // Remove "mermaid" prefix |
| 437 | + } |
| 438 | + |
432 | 439 | // Create a new div for the mermaid diagram |
433 | 440 | const mermaidDiv = document.createElement('div'); |
434 | 441 | mermaidDiv.className = 'mermaid'; |
|
0 commit comments