Spaces:
Paused

dushyantsingh0 commited on
Commit
49aef6e
·
1 Parent(s): e9dcc0c

backend stabilization

Browse files
Files changed (1) hide show
  1. templates/docs.html +45 -18
templates/docs.html CHANGED
@@ -235,25 +235,52 @@
235
 
236
  <script src="https://cdn.jsdelivr.net/npm/mermaid@10.9.1/dist/mermaid.min.js"></script>
237
  <script>
238
- document.addEventListener('DOMContentLoaded', () => {
239
- // Find all mermaid code blocks and convert them to div.mermaid
240
- const codeBlocks = document.querySelectorAll('code.language-mermaid');
241
- codeBlocks.forEach(block => {
242
- const pre = block.parentElement;
243
- const div = document.createElement('div');
244
- div.className = 'mermaid';
245
- div.textContent = block.textContent;
246
- pre.replaceWith(div);
247
- });
248
-
249
- // Initialize Mermaid
250
- mermaid.initialize({
251
- startOnLoad: true,
252
- theme: 'neutral',
253
- securityLevel: 'loose',
254
- fontFamily: 'Inter'
255
- });
256
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  </script>
258
  </body>
259
  </html>
 
235
 
236
  <script src="https://cdn.jsdelivr.net/npm/mermaid@10.9.1/dist/mermaid.min.js"></script>
237
  <script>
238
+ mermaid.initialize({
239
+ startOnLoad: false,
240
+ theme: 'neutral',
241
+ securityLevel: 'loose',
242
+ fontFamily: 'Inter'
 
 
 
 
 
 
 
 
 
 
 
 
 
243
  });
244
+
245
+ async function renderMermaid() {
246
+ const blocks = document.querySelectorAll('pre code');
247
+ const keywords = [
248
+ 'graph ', 'sequenceDiagram', 'gantt', 'classDiagram',
249
+ 'stateDiagram', 'pie', 'flowchart', 'erDiagram', 'mindmap', 'gitGraph'
250
+ ];
251
+
252
+ for (const block of blocks) {
253
+ const text = block.textContent.trim();
254
+ const hasKeyword = keywords.some(k => text.startsWith(k) || text.includes('\n' + k) || text.startsWith('---'));
255
+
256
+ const isMermaid =
257
+ block.classList.contains('language-mermaid') ||
258
+ block.classList.contains('mermaid') ||
259
+ (hasKeyword && (text.includes('graph') || text.includes('Diagram') || text.includes('map')));
260
+
261
+ if (isMermaid) {
262
+ const pre = block.parentElement;
263
+ const div = document.createElement('div');
264
+ div.className = 'mermaid';
265
+ div.textContent = text;
266
+
267
+ // Replace the furthest parent container (pre or codehilite)
268
+ let target = pre;
269
+ if (pre.parentElement && pre.parentElement.classList.contains('codehilite')) {
270
+ target = pre.parentElement;
271
+ }
272
+ target.replaceWith(div);
273
+ }
274
+ }
275
+
276
+ try {
277
+ await mermaid.run();
278
+ } catch (err) {
279
+ console.error('Mermaid render failed:', err);
280
+ }
281
+ }
282
+
283
+ document.addEventListener('DOMContentLoaded', renderMermaid);
284
  </script>
285
  </body>
286
  </html>