Spaces:
Sleeping
Sleeping
Update index.html
Browse files- index.html +52 -32
index.html
CHANGED
|
@@ -60,8 +60,15 @@
|
|
| 60 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 61 |
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
<!-- AOS (Animate On Scroll) -->
|
| 64 |
<link href="https://unpkg.com/aos@2.3.4/dist/aos.css" rel="stylesheet" />
|
|
|
|
| 65 |
<script defer src="https://unpkg.com/aos@2.3.4/dist/aos.js"></script>
|
| 66 |
|
| 67 |
<!-- Lucide Icons -->
|
|
@@ -1336,6 +1343,19 @@ L_t = α * CE(y_t) + (1-α) * τ^2 * KL( p_T(·|τ) || p_S(·) )</code></pre>
|
|
| 1336 |
const $ = (sel, root = document) => root.querySelector(sel);
|
| 1337 |
const $$ = (sel, root = document) => Array.from(root.querySelectorAll(sel));
|
| 1338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1339 |
function showToast(msg) {
|
| 1340 |
const t = $('#toast');
|
| 1341 |
if (!t) return;
|
|
@@ -1403,45 +1423,45 @@ L_t = α * CE(y_t) + (1-α) * τ^2 * KL( p_T(·|τ) || p_S(·) )</code></pre>
|
|
| 1403 |
}
|
| 1404 |
|
| 1405 |
// ---------- Mermaid ----------
|
|
|
|
|
|
|
| 1406 |
async function renderMermaid() {
|
| 1407 |
if (!window.mermaid) return;
|
|
|
|
|
|
|
| 1408 |
|
| 1409 |
-
|
| 1410 |
-
|
| 1411 |
-
startOnLoad: false,
|
| 1412 |
-
theme: isDark ? 'dark' : 'default',
|
| 1413 |
-
securityLevel: 'loose',
|
| 1414 |
-
fontFamily: 'Inter, ui-sans-serif, system-ui',
|
| 1415 |
-
flowchart: { useMaxWidth: true, htmlLabels: true }
|
| 1416 |
-
});
|
| 1417 |
|
| 1418 |
-
|
| 1419 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1420 |
|
| 1421 |
-
|
| 1422 |
-
|
| 1423 |
-
if (!el.dataset.mermaidSrc) {
|
| 1424 |
-
const src = (el.textContent || '').trim();
|
| 1425 |
-
// If the element already contains svg (e.g., from previous render), don't overwrite cache
|
| 1426 |
-
if (src.startsWith('<svg')) continue;
|
| 1427 |
-
el.dataset.mermaidSrc = src;
|
| 1428 |
-
}
|
| 1429 |
|
| 1430 |
-
const
|
| 1431 |
-
|
|
|
|
| 1432 |
|
| 1433 |
-
|
| 1434 |
-
const id = `mmd-${idx++}-${Date.now()}`;
|
| 1435 |
|
| 1436 |
-
|
| 1437 |
-
|
| 1438 |
-
|
| 1439 |
-
|
| 1440 |
-
|
| 1441 |
-
|
| 1442 |
-
|
| 1443 |
-
|
|
|
|
| 1444 |
}
|
|
|
|
|
|
|
| 1445 |
}
|
| 1446 |
}
|
| 1447 |
|
|
@@ -1475,7 +1495,7 @@ L_t = α * CE(y_t) + (1-α) * τ^2 * KL( p_T(·|τ) || p_S(·) )</code></pre>
|
|
| 1475 |
if (panel) panel.classList.remove('hidden');
|
| 1476 |
|
| 1477 |
// re-render mermaid if panel contains diagrams
|
| 1478 |
-
requestAnimationFrame(() => renderMermaid());
|
| 1479 |
});
|
| 1480 |
});
|
| 1481 |
}
|
|
@@ -1785,7 +1805,7 @@ L_t = α * CE(y_t) + (1-α) * τ^2 * KL( p_T(·|τ) || p_S(·) )</code></pre>
|
|
| 1785 |
// Render math + mermaid after libs load
|
| 1786 |
setTimeout(() => {
|
| 1787 |
renderMath();
|
| 1788 |
-
renderMermaid();
|
| 1789 |
}, 0);
|
| 1790 |
|
| 1791 |
initGSAP();
|
|
|
|
| 60 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 61 |
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">
|
| 62 |
|
| 63 |
+
<!-- Load mermaid first, prevent default DOM -->
|
| 64 |
+
<script>
|
| 65 |
+
window.mermaid = { startOnLoad: false };
|
| 66 |
+
</script>
|
| 67 |
+
<script defer src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
|
| 68 |
+
|
| 69 |
<!-- AOS (Animate On Scroll) -->
|
| 70 |
<link href="https://unpkg.com/aos@2.3.4/dist/aos.css" rel="stylesheet" />
|
| 71 |
+
|
| 72 |
<script defer src="https://unpkg.com/aos@2.3.4/dist/aos.js"></script>
|
| 73 |
|
| 74 |
<!-- Lucide Icons -->
|
|
|
|
| 1343 |
const $ = (sel, root = document) => root.querySelector(sel);
|
| 1344 |
const $$ = (sel, root = document) => Array.from(root.querySelectorAll(sel));
|
| 1345 |
|
| 1346 |
+
const MERMAID_SRC = new WeakMap();
|
| 1347 |
+
|
| 1348 |
+
function cacheMermaidSources() {
|
| 1349 |
+
document.querySelectorAll('.mermaid').forEach(el => {
|
| 1350 |
+
if (!MERMAID_SRC.has(el)) {
|
| 1351 |
+
MERMAID_SRC.set(el, (el.textContent || '').trim());
|
| 1352 |
+
}
|
| 1353 |
+
});
|
| 1354 |
+
}
|
| 1355 |
+
|
| 1356 |
+
// Cache mermaid src (before any render)
|
| 1357 |
+
cacheMermaidSources();
|
| 1358 |
+
|
| 1359 |
function showToast(msg) {
|
| 1360 |
const t = $('#toast');
|
| 1361 |
if (!t) return;
|
|
|
|
| 1423 |
}
|
| 1424 |
|
| 1425 |
// ---------- Mermaid ----------
|
| 1426 |
+
let _mermaidRendering = false;
|
| 1427 |
+
|
| 1428 |
async function renderMermaid() {
|
| 1429 |
if (!window.mermaid) return;
|
| 1430 |
+
if (_mermaidRendering) return;
|
| 1431 |
+
_mermaidRendering = true;
|
| 1432 |
|
| 1433 |
+
try {
|
| 1434 |
+
const isDark = document.documentElement.classList.contains('dark');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1435 |
|
| 1436 |
+
mermaid.initialize({
|
| 1437 |
+
startOnLoad: false,
|
| 1438 |
+
theme: isDark ? 'dark' : 'default',
|
| 1439 |
+
securityLevel: 'loose',
|
| 1440 |
+
fontFamily: 'Inter, ui-sans-serif, system-ui',
|
| 1441 |
+
flowchart: { useMaxWidth: true, htmlLabels: true }
|
| 1442 |
+
});
|
| 1443 |
|
| 1444 |
+
const blocks = document.querySelectorAll('.mermaid');
|
| 1445 |
+
let idx = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1446 |
|
| 1447 |
+
for (const el of blocks) {
|
| 1448 |
+
const code = (MERMAID_SRC.get(el) || '').trim();
|
| 1449 |
+
if (!code) continue;
|
| 1450 |
|
| 1451 |
+
const id = `mmd-${idx++}-${Date.now()}`;
|
|
|
|
| 1452 |
|
| 1453 |
+
try {
|
| 1454 |
+
const { svg, bindFunctions } = await mermaid.render(id, code);
|
| 1455 |
+
el.innerHTML = svg;
|
| 1456 |
+
if (typeof bindFunctions === 'function') bindFunctions(el);
|
| 1457 |
+
} catch (err) {
|
| 1458 |
+
console.error('Mermaid render error:', err, code);
|
| 1459 |
+
const safe = String(err).replace(/</g, '<').replace(/>/g, '>');
|
| 1460 |
+
el.innerHTML = `<div class="text-red-300 text-sm">Mermaid render failed: ${safe}</div>`;
|
| 1461 |
+
}
|
| 1462 |
}
|
| 1463 |
+
} finally {
|
| 1464 |
+
_mermaidRendering = false;
|
| 1465 |
}
|
| 1466 |
}
|
| 1467 |
|
|
|
|
| 1495 |
if (panel) panel.classList.remove('hidden');
|
| 1496 |
|
| 1497 |
// re-render mermaid if panel contains diagrams
|
| 1498 |
+
requestAnimationFrame(() => await renderMermaid());
|
| 1499 |
});
|
| 1500 |
});
|
| 1501 |
}
|
|
|
|
| 1805 |
// Render math + mermaid after libs load
|
| 1806 |
setTimeout(() => {
|
| 1807 |
renderMath();
|
| 1808 |
+
await renderMermaid();
|
| 1809 |
}, 0);
|
| 1810 |
|
| 1811 |
initGSAP();
|