Skip to content

Commit f575fce

Browse files
Copilotlarp0
andcommitted
Add local mermaid library and improve content processing
Co-authored-by: larp0 <[email protected]>
1 parent 5d86a1c commit f575fce

File tree

2 files changed

+1656
-3
lines changed

2 files changed

+1656
-3
lines changed

docs.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
<!-- Marked.js for markdown parsing - try multiple CDNs for reliability -->
1010
<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>
1313
<script>
1414
// Fallback if marked.js fails to load
1515
if (typeof marked === 'undefined') {
@@ -411,7 +411,7 @@
411411
const codeBlocks = document.querySelectorAll('pre code');
412412

413413
codeBlocks.forEach((codeBlock, index) => {
414-
const text = codeBlock.textContent.trim();
414+
let text = codeBlock.textContent.trim();
415415
const parentPre = codeBlock.parentElement;
416416

417417
// Check if this is a mermaid diagram - look for mermaid language or text starting with flowchart/graph/sequenceDiagram etc.
@@ -429,6 +429,13 @@
429429
text.includes('subgraph');
430430

431431
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+
432439
// Create a new div for the mermaid diagram
433440
const mermaidDiv = document.createElement('div');
434441
mermaidDiv.className = 'mermaid';

mermaid.min.js

Lines changed: 1646 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)