mdsvr 2.6.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/directory.d.ts +2 -0
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +2 -1
- package/dist/directory.js.map +1 -1
- package/dist/generators/search-index.d.ts.map +1 -1
- package/dist/generators/search-index.js +12 -15
- package/dist/generators/search-index.js.map +1 -1
- package/dist/generators/static-export.js +2 -2
- package/dist/generators/static-export.js.map +1 -1
- package/dist/link-transform.d.ts +5 -0
- package/dist/link-transform.d.ts.map +1 -1
- package/dist/link-transform.js +3 -2
- package/dist/link-transform.js.map +1 -1
- package/dist/markdown-fences.d.ts +8 -0
- package/dist/markdown-fences.d.ts.map +1 -0
- package/dist/markdown-fences.js +31 -0
- package/dist/markdown-fences.js.map +1 -0
- package/dist/og/generator.d.ts.map +1 -1
- package/dist/og/generator.js +8 -18
- package/dist/og/generator.js.map +1 -1
- package/dist/render-page.d.ts.map +1 -1
- package/dist/render-page.js +21 -6
- package/dist/render-page.js.map +1 -1
- package/dist/renderer/components.d.ts +5 -0
- package/dist/renderer/components.d.ts.map +1 -1
- package/dist/renderer/components.js +22 -1
- package/dist/renderer/components.js.map +1 -1
- package/dist/renderer/markdown.d.ts.map +1 -1
- package/dist/renderer/markdown.js +14 -2
- package/dist/renderer/markdown.js.map +1 -1
- package/dist/renderer/mdx.d.ts.map +1 -1
- package/dist/renderer/mdx.js +34 -6
- package/dist/renderer/mdx.js.map +1 -1
- package/dist/renderer/mermaid.d.ts +13 -0
- package/dist/renderer/mermaid.d.ts.map +1 -0
- package/dist/renderer/mermaid.js +18 -0
- package/dist/renderer/mermaid.js.map +1 -0
- package/dist/renderer/quiz.d.ts +155 -0
- package/dist/renderer/quiz.d.ts.map +1 -0
- package/dist/renderer/quiz.js +181 -0
- package/dist/renderer/quiz.js.map +1 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +9 -2
- package/dist/router.js.map +1 -1
- package/dist/settings/defaults.d.ts.map +1 -1
- package/dist/settings/defaults.js +1 -0
- package/dist/settings/defaults.js.map +1 -1
- package/dist/template/index.d.ts.map +1 -1
- package/dist/template/index.js +841 -115
- package/dist/template/index.js.map +1 -1
- package/dist/template/search.d.ts.map +1 -1
- package/dist/template/search.js +16 -5
- package/dist/template/search.js.map +1 -1
- package/dist/template/sidebar.d.ts.map +1 -1
- package/dist/template/sidebar.js +5 -11
- package/dist/template/sidebar.js.map +1 -1
- package/dist/validator/index.d.ts +1 -1
- package/dist/validator/index.d.ts.map +1 -1
- package/dist/validator/index.js +145 -45
- package/dist/validator/index.js.map +1 -1
- package/package.json +3 -1
package/dist/template/index.js
CHANGED
|
@@ -69,11 +69,13 @@ export function renderPage(params) {
|
|
|
69
69
|
// Render sidebar if enabled
|
|
70
70
|
const hasSidebar = settings.navigation.sidebar.enabled && sidebar.length > 0;
|
|
71
71
|
const sidebarHtml = hasSidebar
|
|
72
|
-
? `<aside class="sidebar" id="sidebar">${renderSidebar(sidebar, settings, 0, isStaticExport)}</aside>`
|
|
72
|
+
? `<aside class="sidebar" id="sidebar">${renderSidebar(sidebar, settings, 0, isStaticExport)}</aside><div class="sidebar-overlay" onclick="document.getElementById('sidebar').classList.remove('open')"></div>`
|
|
73
73
|
: "";
|
|
74
74
|
// Sidebar toggle buttons
|
|
75
|
+
const menuIcon = `<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="4" x2="20" y1="7" y2="7"/><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="17" y2="17"/></svg>`;
|
|
76
|
+
const panelLeftIcon = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/></svg>`;
|
|
75
77
|
const sidebarToggle = hasSidebar
|
|
76
|
-
? `<button class="sidebar-toggle sidebar-toggle-mobile" onclick="document.getElementById('sidebar').classList.toggle('open')" aria-label="Toggle menu"
|
|
78
|
+
? `<button class="sidebar-toggle sidebar-toggle-mobile" onclick="document.getElementById('sidebar').classList.toggle('open')" aria-label="Toggle menu">${menuIcon}</button><button class="sidebar-toggle sidebar-toggle-desktop" onclick="toggleDesktopSidebar()" aria-label="Toggle sidebar" title="Toggle sidebar">${panelLeftIcon}</button>`
|
|
77
79
|
: "";
|
|
78
80
|
// Render TOC if enabled
|
|
79
81
|
const hasToc = settings.navigation.tocEnabled && toc.length > 0;
|
|
@@ -83,25 +85,40 @@ export function renderPage(params) {
|
|
|
83
85
|
// Search trigger in header
|
|
84
86
|
const searchTrigger = renderSearchTrigger(settings);
|
|
85
87
|
// Theme toggle
|
|
88
|
+
const sunIcon = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/></svg>`;
|
|
89
|
+
const moonIcon = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/></svg>`;
|
|
86
90
|
const themeToggle = settings.appearance.allowThemeToggle
|
|
87
|
-
? `<button class="theme-toggle" onclick="toggleTheme()" title="Toggle theme">
|
|
88
|
-
<span class="theme-icon-light"
|
|
89
|
-
<span class="theme-icon-dark"
|
|
91
|
+
? `<button class="theme-toggle" onclick="toggleTheme()" title="Toggle theme" aria-label="Toggle theme">
|
|
92
|
+
<span class="theme-icon-light">${sunIcon}</span>
|
|
93
|
+
<span class="theme-icon-dark">${moonIcon}</span>
|
|
90
94
|
</button>`
|
|
91
95
|
: "";
|
|
92
96
|
const viewToggle = `<button class="view-toggle" onclick="toggleContentView()" title="Use wide content view" aria-label="Use wide content view" aria-pressed="false">
|
|
93
|
-
<span class="view-icon-contained" aria-hidden="true"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
|
94
|
-
<span class="view-icon-wide" aria-hidden="true"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
|
97
|
+
<span class="view-icon-contained" aria-hidden="true"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v20"/><path d="M20.288 16.703A1 1 0 0 0 22 16V8a1 1 0 0 0-1.712-.703l-3.99 3.991a1 1 0 0 0-.001 1.424z"/><path d="M3.712 16.703A1 1 0 0 1 2 16V8a1 1 0 0 1 1.712-.703l3.99 3.991a1 1 0 0 1 .001 1.424z"/></svg></span>
|
|
98
|
+
<span class="view-icon-wide" aria-hidden="true"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v20"/><path d="M17.712 16.703A1 1 0 0 1 15.999 16V8a1 1 0 0 1 1.713-.703l3.99 3.991a1 1 0 0 1 .001 1.424z"/><path d="M6.288 16.703A1 1 0 0 0 8.001 16V8a1 1 0 0 0-1.713-.703l-3.99 3.991a1 1 0 0 0-.001 1.424z"/></svg></span>
|
|
95
99
|
</button>`;
|
|
96
100
|
// Logo/header
|
|
97
101
|
const logoHref = settings.site.logo
|
|
98
102
|
? settings.site.logo.href
|
|
99
103
|
: withBasePath("/", settings, isStaticExport);
|
|
100
|
-
|
|
101
|
-
|
|
104
|
+
let logoHtml;
|
|
105
|
+
if (settings.site.logo) {
|
|
106
|
+
logoHtml = `<a href="${logoHref}" class="site-logo">
|
|
102
107
|
<img src="${settings.site.logo.src}" alt="${settings.site.logo.alt}" />
|
|
103
|
-
</a
|
|
104
|
-
|
|
108
|
+
</a>`;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const [siteName, ...tagParts] = settings.site.title.split("|");
|
|
112
|
+
const siteTag = tagParts.join("|").trim();
|
|
113
|
+
const mark = escapeHtml((siteName.trim().charAt(0) || "M").toUpperCase());
|
|
114
|
+
logoHtml = `<a href="${logoHref}" class="site-logo">
|
|
115
|
+
<span class="site-logo-mark" aria-hidden="true">${mark}</span>
|
|
116
|
+
<span class="site-logo-text">
|
|
117
|
+
<span class="site-logo-name">${escapeHtml(siteName.trim())}</span>
|
|
118
|
+
${siteTag ? `<span class="site-logo-sep" aria-hidden="true">/</span><span class="site-logo-tag">${escapeHtml(siteTag)}</span>` : ""}
|
|
119
|
+
</span>
|
|
120
|
+
</a>`;
|
|
121
|
+
}
|
|
105
122
|
// Footer
|
|
106
123
|
const footerLinks = settings.footer.links
|
|
107
124
|
.map((link) => `<a href="${link.href}">${escapeHtml(link.label)}</a>`)
|
|
@@ -175,33 +192,11 @@ ${getHighlightJsStyles(settings)}
|
|
|
175
192
|
${settings.search.enabled ? getSearchInlineScript(settings.generate.basePath) : ""}
|
|
176
193
|
|
|
177
194
|
<script>
|
|
178
|
-
function rerenderMermaid(theme) {
|
|
179
|
-
if (!window.__mermaid) return;
|
|
180
|
-
var diagrams = document.querySelectorAll(".mermaid");
|
|
181
|
-
if (!diagrams.length) return;
|
|
182
|
-
|
|
183
|
-
diagrams.forEach(function (el) {
|
|
184
|
-
var src = el.getAttribute("data-mermaid-src");
|
|
185
|
-
if (src) el.textContent = src;
|
|
186
|
-
else {
|
|
187
|
-
el.setAttribute("data-mermaid-src", el.textContent);
|
|
188
|
-
}
|
|
189
|
-
el.removeAttribute("data-processed");
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
window.__mermaid.initialize({
|
|
193
|
-
startOnLoad: false,
|
|
194
|
-
theme: theme === "dark" ? "dark" : "default",
|
|
195
|
-
});
|
|
196
|
-
window.__mermaid.run({ nodes: diagrams });
|
|
197
|
-
}
|
|
198
|
-
|
|
199
195
|
function toggleTheme() {
|
|
200
196
|
var current = document.documentElement.getAttribute('data-theme');
|
|
201
197
|
var next = current === 'dark' ? 'light' : 'dark';
|
|
202
198
|
document.documentElement.setAttribute('data-theme', next);
|
|
203
199
|
localStorage.setItem('theme', next);
|
|
204
|
-
rerenderMermaid(next);
|
|
205
200
|
}
|
|
206
201
|
|
|
207
202
|
function updateContentViewToggle() {
|
|
@@ -243,23 +238,32 @@ function initSidebarToggle() {
|
|
|
243
238
|
var isExpanded = header.getAttribute('data-expanded') === 'true';
|
|
244
239
|
var next = !isExpanded;
|
|
245
240
|
header.setAttribute('data-expanded', String(next));
|
|
241
|
+
var toggle = header.querySelector('.nav-toggle');
|
|
242
|
+
if (toggle) {
|
|
243
|
+
toggle.setAttribute('aria-expanded', String(next));
|
|
244
|
+
}
|
|
246
245
|
var navItem = header.closest('.nav-item');
|
|
247
246
|
var children = navItem.querySelector('.nav-children');
|
|
248
247
|
if (children) {
|
|
249
248
|
children.setAttribute('data-expanded', String(next));
|
|
250
249
|
}
|
|
251
|
-
var iconSpan = header.querySelector('.folder-icon');
|
|
252
|
-
if (iconSpan) {
|
|
253
|
-
iconSpan.textContent = next ? '📂' : '📁';
|
|
254
|
-
}
|
|
255
|
-
var link = header.querySelector('.nav-link[data-folder-icon]');
|
|
256
|
-
if (link) {
|
|
257
|
-
link.setAttribute('data-folder-icon', next ? 'open' : 'closed');
|
|
258
|
-
}
|
|
259
250
|
});
|
|
260
251
|
});
|
|
261
252
|
}
|
|
262
253
|
|
|
254
|
+
// Keep the active page visible inside the sidebar without touching page scroll
|
|
255
|
+
function scrollActiveNavIntoView() {
|
|
256
|
+
var sidebar = document.getElementById('sidebar');
|
|
257
|
+
if (!sidebar) return;
|
|
258
|
+
var active = sidebar.querySelector('li.nav-item.active .nav-link');
|
|
259
|
+
if (!active) return;
|
|
260
|
+
var linkRect = active.getBoundingClientRect();
|
|
261
|
+
var sideRect = sidebar.getBoundingClientRect();
|
|
262
|
+
if (linkRect.top < sideRect.top || linkRect.bottom > sideRect.bottom) {
|
|
263
|
+
sidebar.scrollTop += linkRect.top - sideRect.top - sideRect.height / 3;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
263
267
|
// Listen for system theme changes
|
|
264
268
|
if (window.matchMedia) {
|
|
265
269
|
var mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
@@ -267,7 +271,6 @@ if (window.matchMedia) {
|
|
|
267
271
|
if (localStorage.getItem('theme') === 'system' || !localStorage.getItem('theme')) {
|
|
268
272
|
var next = e.matches ? 'dark' : 'light';
|
|
269
273
|
document.documentElement.setAttribute('data-theme', next);
|
|
270
|
-
rerenderMermaid(next);
|
|
271
274
|
}
|
|
272
275
|
});
|
|
273
276
|
}
|
|
@@ -700,40 +703,299 @@ function initTableToolbars() {
|
|
|
700
703
|
});
|
|
701
704
|
}
|
|
702
705
|
|
|
706
|
+
// Quiz interactivity: grade answers client-side, persist stats per-user in
|
|
707
|
+
// localStorage. Answers live in data-answer attributes (honor system — this
|
|
708
|
+
// is self-study, not a secure assessment).
|
|
709
|
+
function initQuizzes() {
|
|
710
|
+
function readStats(quizId) {
|
|
711
|
+
try {
|
|
712
|
+
var raw = localStorage.getItem('mdsvr-quiz:' + quizId);
|
|
713
|
+
return raw ? JSON.parse(raw) : null;
|
|
714
|
+
} catch (e) { return null; }
|
|
715
|
+
}
|
|
716
|
+
function saveStats(quizId, score, total) {
|
|
717
|
+
var stats = readStats(quizId) || { attempts: 0, best: 0 };
|
|
718
|
+
stats.attempts += 1;
|
|
719
|
+
stats.last = score;
|
|
720
|
+
stats.total = total;
|
|
721
|
+
stats.best = Math.max(stats.best || 0, score);
|
|
722
|
+
stats.lastAt = Math.floor(Date.now() / 1000);
|
|
723
|
+
try {
|
|
724
|
+
localStorage.setItem('mdsvr-quiz:' + quizId, JSON.stringify(stats));
|
|
725
|
+
} catch (e) { /* storage unavailable */ }
|
|
726
|
+
return stats;
|
|
727
|
+
}
|
|
728
|
+
function attemptsLabel(stats) {
|
|
729
|
+
return 'Best: ' + stats.best + '/' + stats.total + ' · ' + stats.attempts + (stats.attempts === 1 ? ' attempt' : ' attempts');
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
document.querySelectorAll('.quiz').forEach(function(quiz) {
|
|
733
|
+
if (quiz.classList.contains('quiz-error')) return;
|
|
734
|
+
var quizId = quiz.getAttribute('data-quiz-id') || '';
|
|
735
|
+
var mode = quiz.getAttribute('data-quiz-mode') || 'exam';
|
|
736
|
+
var questions = Array.prototype.slice.call(quiz.querySelectorAll('.quiz-question'));
|
|
737
|
+
var progressEl = quiz.querySelector('.quiz-progress');
|
|
738
|
+
var checkBtn = quiz.querySelector('.quiz-check');
|
|
739
|
+
var resetBtn = quiz.querySelector('.quiz-reset');
|
|
740
|
+
var resultEl = quiz.querySelector('.quiz-result');
|
|
741
|
+
if (mode === 'practice' && checkBtn) checkBtn.hidden = true;
|
|
742
|
+
|
|
743
|
+
function isAnswered(q) {
|
|
744
|
+
if (q.getAttribute('data-qtype') === 'self-check') {
|
|
745
|
+
return !!q.getAttribute('data-marked');
|
|
746
|
+
}
|
|
747
|
+
var inputs = q.querySelectorAll('.quiz-option input');
|
|
748
|
+
for (var i = 0; i < inputs.length; i++) {
|
|
749
|
+
if (inputs[i].checked) return true;
|
|
750
|
+
}
|
|
751
|
+
return false;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
function updateProgress() {
|
|
755
|
+
if (!progressEl) return;
|
|
756
|
+
var answered = 0;
|
|
757
|
+
questions.forEach(function(q) { if (isAnswered(q)) answered++; });
|
|
758
|
+
var stats = readStats(quizId);
|
|
759
|
+
var text = answered + '/' + questions.length;
|
|
760
|
+
if (stats && stats.attempts) text += ' · ' + attemptsLabel(stats);
|
|
761
|
+
progressEl.textContent = text;
|
|
762
|
+
}
|
|
763
|
+
updateProgress();
|
|
764
|
+
|
|
765
|
+
function gradeQuestion(q) {
|
|
766
|
+
var qtype = q.getAttribute('data-qtype');
|
|
767
|
+
var explanation = q.querySelector('.quiz-explanation');
|
|
768
|
+
if (explanation) explanation.hidden = false;
|
|
769
|
+
|
|
770
|
+
if (qtype === 'self-check') {
|
|
771
|
+
var model = q.querySelector('.quiz-model-answer');
|
|
772
|
+
var selfMark = q.querySelector('.quiz-self-mark');
|
|
773
|
+
if (model) model.hidden = false;
|
|
774
|
+
if (selfMark) selfMark.hidden = false;
|
|
775
|
+
var marked = q.getAttribute('data-marked');
|
|
776
|
+
if (!marked) return 'unanswered';
|
|
777
|
+
q.classList.add(marked === 'correct' ? 'answered-correct' : 'answered-incorrect');
|
|
778
|
+
return marked === 'correct' ? 'correct' : 'incorrect';
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
var answer = q.getAttribute('data-answer') || '';
|
|
782
|
+
var labels = q.querySelectorAll('.quiz-option');
|
|
783
|
+
var answered = false;
|
|
784
|
+
var correct = false;
|
|
785
|
+
|
|
786
|
+
if (qtype === 'multiple') {
|
|
787
|
+
var expected = {};
|
|
788
|
+
answer.split(',').forEach(function(a) { expected[a.trim()] = true; });
|
|
789
|
+
var seen = {};
|
|
790
|
+
correct = true;
|
|
791
|
+
labels.forEach(function(label, idx) {
|
|
792
|
+
var input = label.querySelector('input');
|
|
793
|
+
var isExpected = expected[String(idx)] === true;
|
|
794
|
+
if (input.checked) {
|
|
795
|
+
answered = true;
|
|
796
|
+
if (isExpected) {
|
|
797
|
+
seen[String(idx)] = true;
|
|
798
|
+
label.classList.add('correct');
|
|
799
|
+
} else {
|
|
800
|
+
correct = false;
|
|
801
|
+
label.classList.add('incorrect');
|
|
802
|
+
}
|
|
803
|
+
} else if (isExpected) {
|
|
804
|
+
label.classList.add('correct');
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
if (answered) {
|
|
808
|
+
for (var k in expected) { if (!seen[k]) correct = false; }
|
|
809
|
+
}
|
|
810
|
+
} else {
|
|
811
|
+
var correctIdx = qtype === 'single'
|
|
812
|
+
? parseInt(answer, 10)
|
|
813
|
+
: (answer === 'true' ? 0 : 1);
|
|
814
|
+
var checkedIdx = -1;
|
|
815
|
+
labels.forEach(function(label, idx) {
|
|
816
|
+
var input = label.querySelector('input');
|
|
817
|
+
if (input.checked) { checkedIdx = idx; answered = true; }
|
|
818
|
+
if (idx === correctIdx) label.classList.add('correct');
|
|
819
|
+
});
|
|
820
|
+
if (answered && checkedIdx !== correctIdx) {
|
|
821
|
+
labels[checkedIdx].classList.add('incorrect');
|
|
822
|
+
}
|
|
823
|
+
correct = checkedIdx === correctIdx;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
if (!answered) return 'unanswered';
|
|
827
|
+
q.classList.add(correct ? 'answered-correct' : 'answered-incorrect');
|
|
828
|
+
return correct ? 'correct' : 'incorrect';
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
function lockQuestion(q) {
|
|
832
|
+
q.classList.add('graded');
|
|
833
|
+
q.querySelectorAll('input').forEach(function(input) { input.disabled = true; });
|
|
834
|
+
q.querySelectorAll('button').forEach(function(btn) {
|
|
835
|
+
if (!btn.classList.contains('quiz-reveal')) btn.disabled = true;
|
|
836
|
+
});
|
|
837
|
+
var reveal = q.querySelector('.quiz-reveal');
|
|
838
|
+
if (reveal) reveal.hidden = true;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
function showResult() {
|
|
842
|
+
if (!resultEl) return;
|
|
843
|
+
var correct = 0;
|
|
844
|
+
var unanswered = 0;
|
|
845
|
+
var byType = {};
|
|
846
|
+
questions.forEach(function(q) {
|
|
847
|
+
var r = q.getAttribute('data-result');
|
|
848
|
+
var t = q.getAttribute('data-qtype') || '?';
|
|
849
|
+
if (!byType[t]) byType[t] = { c: 0, n: 0 };
|
|
850
|
+
byType[t].n++;
|
|
851
|
+
if (r === 'correct') { correct++; byType[t].c++; }
|
|
852
|
+
else if (r === 'unanswered') unanswered++;
|
|
853
|
+
});
|
|
854
|
+
var total = questions.length;
|
|
855
|
+
var pct = total ? Math.round((correct / total) * 100) : 0;
|
|
856
|
+
var stats = saveStats(quizId, correct, total);
|
|
857
|
+
var parts = [];
|
|
858
|
+
for (var t in byType) parts.push(t + ' ' + byType[t].c + '/' + byType[t].n);
|
|
859
|
+
resultEl.innerHTML =
|
|
860
|
+
'<div class="quiz-score">Correct ' + correct + '/' + total + ' — ' + pct + '%' + (unanswered ? ' · ' + unanswered + ' unanswered' : '') + '</div>' +
|
|
861
|
+
'<div class="quiz-breakdown">' + parts.join(' · ') + '</div>' +
|
|
862
|
+
'<div class="quiz-history">' + attemptsLabel(stats) + '</div>';
|
|
863
|
+
resultEl.hidden = false;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
function finishAttempt() {
|
|
867
|
+
questions.forEach(function(q) {
|
|
868
|
+
q.setAttribute('data-result', gradeQuestion(q));
|
|
869
|
+
lockQuestion(q);
|
|
870
|
+
});
|
|
871
|
+
if (checkBtn) checkBtn.hidden = true;
|
|
872
|
+
if (resetBtn) resetBtn.hidden = false;
|
|
873
|
+
showResult();
|
|
874
|
+
updateProgress();
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
if (checkBtn) {
|
|
878
|
+
checkBtn.addEventListener('click', function() {
|
|
879
|
+
if (mode !== 'exam') return;
|
|
880
|
+
finishAttempt();
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
// Practice mode: per-question check buttons grade one question at a time.
|
|
885
|
+
questions.forEach(function(q) {
|
|
886
|
+
var practiceBtn = q.querySelector('.quiz-practice-check');
|
|
887
|
+
if (practiceBtn) {
|
|
888
|
+
practiceBtn.addEventListener('click', function() {
|
|
889
|
+
if (q.classList.contains('graded')) return;
|
|
890
|
+
q.setAttribute('data-result', gradeQuestion(q));
|
|
891
|
+
lockQuestion(q);
|
|
892
|
+
var allGraded = questions.every(function(qq) { return qq.classList.contains('graded'); });
|
|
893
|
+
if (allGraded) {
|
|
894
|
+
if (resetBtn) resetBtn.hidden = false;
|
|
895
|
+
showResult();
|
|
896
|
+
}
|
|
897
|
+
updateProgress();
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
});
|
|
901
|
+
|
|
902
|
+
// Self-check: reveal model answer, then let the user self-report.
|
|
903
|
+
questions.forEach(function(q) {
|
|
904
|
+
if (q.getAttribute('data-qtype') !== 'self-check') return;
|
|
905
|
+
var reveal = q.querySelector('.quiz-reveal');
|
|
906
|
+
var model = q.querySelector('.quiz-model-answer');
|
|
907
|
+
var selfMark = q.querySelector('.quiz-self-mark');
|
|
908
|
+
if (reveal) {
|
|
909
|
+
reveal.addEventListener('click', function() {
|
|
910
|
+
if (model) model.hidden = false;
|
|
911
|
+
if (selfMark) selfMark.hidden = false;
|
|
912
|
+
reveal.hidden = true;
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
if (selfMark) {
|
|
916
|
+
selfMark.querySelectorAll('button[data-mark]').forEach(function(btn) {
|
|
917
|
+
btn.addEventListener('click', function() {
|
|
918
|
+
q.setAttribute('data-marked', btn.getAttribute('data-mark'));
|
|
919
|
+
selfMark.querySelectorAll('button').forEach(function(b) { b.classList.remove('selected'); });
|
|
920
|
+
btn.classList.add('selected');
|
|
921
|
+
updateProgress();
|
|
922
|
+
// In practice mode a self-mark resolves the question immediately.
|
|
923
|
+
if (mode === 'practice' && !q.classList.contains('graded')) {
|
|
924
|
+
q.setAttribute('data-result', gradeQuestion(q));
|
|
925
|
+
lockQuestion(q);
|
|
926
|
+
var allGraded = questions.every(function(qq) { return qq.classList.contains('graded'); });
|
|
927
|
+
if (allGraded) {
|
|
928
|
+
if (resetBtn) resetBtn.hidden = false;
|
|
929
|
+
showResult();
|
|
930
|
+
}
|
|
931
|
+
updateProgress();
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
|
|
938
|
+
quiz.addEventListener('change', function(e) {
|
|
939
|
+
if (e.target && e.target.matches && e.target.matches('.quiz-option input')) {
|
|
940
|
+
updateProgress();
|
|
941
|
+
}
|
|
942
|
+
});
|
|
943
|
+
|
|
944
|
+
if (resetBtn) {
|
|
945
|
+
resetBtn.addEventListener('click', function() {
|
|
946
|
+
questions.forEach(function(q) {
|
|
947
|
+
q.classList.remove('graded', 'answered-correct', 'answered-incorrect');
|
|
948
|
+
q.removeAttribute('data-result');
|
|
949
|
+
q.removeAttribute('data-marked');
|
|
950
|
+
q.querySelectorAll('input').forEach(function(input) {
|
|
951
|
+
input.checked = false;
|
|
952
|
+
input.disabled = false;
|
|
953
|
+
});
|
|
954
|
+
q.querySelectorAll('button').forEach(function(btn) { btn.disabled = false; });
|
|
955
|
+
q.querySelectorAll('.quiz-option').forEach(function(label) {
|
|
956
|
+
label.classList.remove('correct', 'incorrect');
|
|
957
|
+
});
|
|
958
|
+
q.querySelectorAll('.quiz-explanation, .quiz-model-answer, .quiz-self-mark').forEach(function(el) {
|
|
959
|
+
el.hidden = true;
|
|
960
|
+
});
|
|
961
|
+
var reveal = q.querySelector('.quiz-reveal');
|
|
962
|
+
if (reveal) reveal.hidden = false;
|
|
963
|
+
q.querySelectorAll('.quiz-self-mark button').forEach(function(btn) {
|
|
964
|
+
btn.classList.remove('selected');
|
|
965
|
+
});
|
|
966
|
+
});
|
|
967
|
+
if (resultEl) { resultEl.hidden = true; resultEl.innerHTML = ''; }
|
|
968
|
+
resetBtn.hidden = true;
|
|
969
|
+
if (checkBtn && mode === 'exam') checkBtn.hidden = false;
|
|
970
|
+
updateProgress();
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
|
|
703
976
|
// Initialize sidebar toggle on DOM ready
|
|
704
977
|
if (document.readyState === 'loading') {
|
|
705
978
|
document.addEventListener('DOMContentLoaded', function() {
|
|
706
979
|
initSidebarState();
|
|
707
980
|
initSidebarToggle();
|
|
981
|
+
scrollActiveNavIntoView();
|
|
708
982
|
updateContentViewToggle();
|
|
709
983
|
initMermaidToolbars();
|
|
710
984
|
initCodeBlockToolbars();
|
|
711
985
|
initTableToolbars();
|
|
986
|
+
initQuizzes();
|
|
712
987
|
});
|
|
713
988
|
} else {
|
|
714
989
|
initSidebarState();
|
|
715
990
|
initSidebarToggle();
|
|
991
|
+
scrollActiveNavIntoView();
|
|
716
992
|
updateContentViewToggle();
|
|
717
993
|
initMermaidToolbars();
|
|
718
994
|
initCodeBlockToolbars();
|
|
719
995
|
initTableToolbars();
|
|
996
|
+
initQuizzes();
|
|
720
997
|
}
|
|
721
998
|
</script>
|
|
722
|
-
|
|
723
|
-
<script type="module">
|
|
724
|
-
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
|
|
725
|
-
const isDark = document.documentElement.getAttribute('data-theme') === 'dark';
|
|
726
|
-
const diagrams = document.querySelectorAll('.mermaid');
|
|
727
|
-
diagrams.forEach(function(el) {
|
|
728
|
-
el.setAttribute('data-mermaid-src', el.textContent);
|
|
729
|
-
});
|
|
730
|
-
mermaid.initialize({
|
|
731
|
-
startOnLoad: false,
|
|
732
|
-
theme: isDark ? 'dark' : 'default',
|
|
733
|
-
});
|
|
734
|
-
mermaid.run({ nodes: diagrams });
|
|
735
|
-
window.__mermaid = mermaid;
|
|
736
|
-
</script>
|
|
737
999
|
</body>
|
|
738
1000
|
</html>`;
|
|
739
1001
|
}
|
|
@@ -800,6 +1062,7 @@ function getBaseStyles(settings) {
|
|
|
800
1062
|
return `
|
|
801
1063
|
:root {
|
|
802
1064
|
--accent-color: ${accentColor};
|
|
1065
|
+
--header-height: 56px;
|
|
803
1066
|
}
|
|
804
1067
|
|
|
805
1068
|
:root[data-theme="light"] {
|
|
@@ -842,57 +1105,173 @@ body {
|
|
|
842
1105
|
top: 0;
|
|
843
1106
|
left: 0;
|
|
844
1107
|
right: 0;
|
|
845
|
-
height:
|
|
846
|
-
background: var(--bg
|
|
1108
|
+
height: var(--header-height);
|
|
1109
|
+
background: var(--bg);
|
|
1110
|
+
background: color-mix(in srgb, var(--bg) 82%, transparent);
|
|
1111
|
+
backdrop-filter: blur(14px) saturate(1.5);
|
|
1112
|
+
-webkit-backdrop-filter: blur(14px) saturate(1.5);
|
|
847
1113
|
border-bottom: 1px solid var(--border);
|
|
848
1114
|
display: flex;
|
|
849
1115
|
align-items: center;
|
|
850
1116
|
justify-content: space-between;
|
|
851
|
-
padding: 0
|
|
1117
|
+
padding: 0 16px 0 12px;
|
|
852
1118
|
z-index: 100;
|
|
853
1119
|
}
|
|
854
1120
|
|
|
855
1121
|
.header-left, .header-right {
|
|
856
1122
|
display: flex;
|
|
857
1123
|
align-items: center;
|
|
858
|
-
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
.header-left {
|
|
1127
|
+
gap: 4px;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
.header-right {
|
|
1131
|
+
gap: 6px;
|
|
859
1132
|
}
|
|
860
1133
|
|
|
861
1134
|
.site-logo {
|
|
862
1135
|
color: var(--text);
|
|
863
|
-
font-weight: 600;
|
|
864
|
-
font-size: 18px;
|
|
865
1136
|
text-decoration: none;
|
|
866
1137
|
display: flex;
|
|
867
1138
|
align-items: center;
|
|
868
|
-
gap:
|
|
1139
|
+
gap: 9px;
|
|
1140
|
+
margin-left: 6px;
|
|
1141
|
+
min-width: 0;
|
|
869
1142
|
}
|
|
870
1143
|
|
|
871
1144
|
.site-logo img {
|
|
872
|
-
height:
|
|
1145
|
+
height: 26px;
|
|
873
1146
|
width: auto;
|
|
874
1147
|
}
|
|
875
1148
|
|
|
876
|
-
.
|
|
877
|
-
|
|
1149
|
+
.site-logo-mark {
|
|
1150
|
+
width: 26px;
|
|
1151
|
+
height: 26px;
|
|
1152
|
+
border-radius: 7px;
|
|
1153
|
+
display: flex;
|
|
1154
|
+
align-items: center;
|
|
1155
|
+
justify-content: center;
|
|
1156
|
+
flex-shrink: 0;
|
|
1157
|
+
font-size: 13px;
|
|
1158
|
+
font-weight: 700;
|
|
1159
|
+
letter-spacing: -0.02em;
|
|
1160
|
+
color: var(--accent);
|
|
1161
|
+
background: color-mix(in srgb, var(--accent) 13%, transparent);
|
|
1162
|
+
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
.site-logo-text {
|
|
1166
|
+
display: flex;
|
|
1167
|
+
align-items: baseline;
|
|
1168
|
+
min-width: 0;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
.site-logo-name {
|
|
1172
|
+
font-weight: 600;
|
|
1173
|
+
font-size: 15px;
|
|
1174
|
+
letter-spacing: -0.01em;
|
|
1175
|
+
white-space: nowrap;
|
|
1176
|
+
transition: color 0.12s ease;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
.site-logo:hover .site-logo-name {
|
|
1180
|
+
color: var(--accent);
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
.site-logo-sep {
|
|
1184
|
+
color: var(--border);
|
|
1185
|
+
font-weight: 300;
|
|
1186
|
+
margin: 0 9px;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
.site-logo-tag {
|
|
1190
|
+
color: var(--text-muted);
|
|
1191
|
+
font-size: 13px;
|
|
1192
|
+
white-space: nowrap;
|
|
1193
|
+
overflow: hidden;
|
|
1194
|
+
text-overflow: ellipsis;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
.search-trigger {
|
|
1198
|
+
display: flex;
|
|
1199
|
+
align-items: center;
|
|
1200
|
+
gap: 8px;
|
|
1201
|
+
height: 34px;
|
|
1202
|
+
width: 240px;
|
|
1203
|
+
padding: 0 8px 0 10px;
|
|
878
1204
|
border: 1px solid var(--border);
|
|
1205
|
+
border-radius: 8px;
|
|
1206
|
+
background: var(--bg-secondary);
|
|
879
1207
|
color: var(--text-muted);
|
|
880
|
-
height: 36px;
|
|
881
|
-
padding: 0 12px;
|
|
882
|
-
border-radius: 6px;
|
|
883
1208
|
cursor: pointer;
|
|
884
|
-
font-size:
|
|
1209
|
+
font-size: 13px;
|
|
1210
|
+
transition: border-color 0.15s ease, color 0.15s ease;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
.search-trigger:hover {
|
|
1214
|
+
border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
|
|
1215
|
+
color: var(--text);
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
.search-trigger svg {
|
|
1219
|
+
flex-shrink: 0;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
.search-trigger-label {
|
|
1223
|
+
flex: 1;
|
|
1224
|
+
text-align: left;
|
|
1225
|
+
white-space: nowrap;
|
|
1226
|
+
overflow: hidden;
|
|
1227
|
+
text-overflow: ellipsis;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
.search-shortcut {
|
|
1231
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
1232
|
+
font-size: 11px;
|
|
1233
|
+
line-height: 1;
|
|
1234
|
+
padding: 3px 5px;
|
|
1235
|
+
border: 1px solid var(--border);
|
|
1236
|
+
border-radius: 5px;
|
|
1237
|
+
background: var(--bg);
|
|
1238
|
+
color: var(--text-muted);
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
.theme-toggle, .view-toggle, .sidebar-toggle {
|
|
1242
|
+
background: transparent;
|
|
1243
|
+
border: none;
|
|
1244
|
+
color: var(--text-muted);
|
|
1245
|
+
width: 32px;
|
|
1246
|
+
height: 32px;
|
|
1247
|
+
padding: 0;
|
|
1248
|
+
border-radius: 8px;
|
|
1249
|
+
cursor: pointer;
|
|
885
1250
|
display: flex;
|
|
886
1251
|
align-items: center;
|
|
887
|
-
|
|
1252
|
+
justify-content: center;
|
|
1253
|
+
transition: background 0.12s ease, color 0.12s ease;
|
|
888
1254
|
}
|
|
889
1255
|
|
|
890
|
-
.
|
|
891
|
-
|
|
892
|
-
border-color: var(--accent);
|
|
1256
|
+
.theme-toggle:hover, .view-toggle:hover, .sidebar-toggle:hover {
|
|
1257
|
+
background: color-mix(in srgb, var(--text) 7%, transparent);
|
|
893
1258
|
color: var(--text);
|
|
894
1259
|
}
|
|
895
1260
|
|
|
1261
|
+
.theme-icon-light, .theme-icon-dark,
|
|
1262
|
+
.view-icon-contained, .view-icon-wide {
|
|
1263
|
+
display: flex;
|
|
1264
|
+
align-items: center;
|
|
1265
|
+
justify-content: center;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
.search-trigger:focus-visible, .theme-toggle:focus-visible,
|
|
1269
|
+
.view-toggle:focus-visible, .sidebar-toggle:focus-visible,
|
|
1270
|
+
.site-logo:focus-visible {
|
|
1271
|
+
outline: 2px solid var(--accent);
|
|
1272
|
+
outline-offset: 2px;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
896
1275
|
.view-icon-wide {
|
|
897
1276
|
display: none;
|
|
898
1277
|
}
|
|
@@ -905,11 +1284,6 @@ body {
|
|
|
905
1284
|
display: flex;
|
|
906
1285
|
}
|
|
907
1286
|
|
|
908
|
-
.sidebar-toggle {
|
|
909
|
-
font-size: 18px;
|
|
910
|
-
padding: 6px 10px;
|
|
911
|
-
}
|
|
912
|
-
|
|
913
1287
|
.sidebar-toggle-mobile {
|
|
914
1288
|
display: none;
|
|
915
1289
|
}
|
|
@@ -918,6 +1292,12 @@ body {
|
|
|
918
1292
|
display: flex;
|
|
919
1293
|
}
|
|
920
1294
|
|
|
1295
|
+
@media (max-width: 860px) {
|
|
1296
|
+
.site-logo-sep, .site-logo-tag {
|
|
1297
|
+
display: none;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
|
|
921
1301
|
@media (max-width: 768px) {
|
|
922
1302
|
.sidebar-toggle-mobile {
|
|
923
1303
|
display: flex;
|
|
@@ -926,6 +1306,20 @@ body {
|
|
|
926
1306
|
.view-toggle {
|
|
927
1307
|
display: none;
|
|
928
1308
|
}
|
|
1309
|
+
.search-trigger {
|
|
1310
|
+
width: 32px;
|
|
1311
|
+
padding: 0;
|
|
1312
|
+
justify-content: center;
|
|
1313
|
+
border-color: transparent;
|
|
1314
|
+
background: transparent;
|
|
1315
|
+
}
|
|
1316
|
+
.search-trigger:hover {
|
|
1317
|
+
background: color-mix(in srgb, var(--text) 7%, transparent);
|
|
1318
|
+
border-color: transparent;
|
|
1319
|
+
}
|
|
1320
|
+
.search-trigger-label, .search-shortcut {
|
|
1321
|
+
display: none;
|
|
1322
|
+
}
|
|
929
1323
|
}
|
|
930
1324
|
|
|
931
1325
|
@media (min-width: 769px) {
|
|
@@ -945,15 +1339,10 @@ body {
|
|
|
945
1339
|
}
|
|
946
1340
|
}
|
|
947
1341
|
|
|
948
|
-
.search-shortcut {
|
|
949
|
-
font-size: 12px;
|
|
950
|
-
opacity: 0.6;
|
|
951
|
-
}
|
|
952
|
-
|
|
953
1342
|
.site-container {
|
|
954
1343
|
display: flex;
|
|
955
|
-
margin-top:
|
|
956
|
-
min-height: calc(100vh -
|
|
1344
|
+
margin-top: var(--header-height);
|
|
1345
|
+
min-height: calc(100vh - var(--header-height));
|
|
957
1346
|
}
|
|
958
1347
|
|
|
959
1348
|
.sidebar {
|
|
@@ -961,13 +1350,36 @@ body {
|
|
|
961
1350
|
flex-shrink: 0;
|
|
962
1351
|
background: var(--bg-secondary);
|
|
963
1352
|
border-right: 1px solid var(--border);
|
|
964
|
-
padding:
|
|
1353
|
+
padding: 16px 12px 32px;
|
|
965
1354
|
overflow-y: auto;
|
|
966
1355
|
position: fixed;
|
|
967
|
-
top:
|
|
1356
|
+
top: var(--header-height);
|
|
968
1357
|
bottom: 0;
|
|
969
1358
|
left: 0;
|
|
970
1359
|
transition: transform 0.25s ease;
|
|
1360
|
+
scrollbar-width: thin;
|
|
1361
|
+
scrollbar-color: var(--border) transparent;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
.sidebar::-webkit-scrollbar {
|
|
1365
|
+
width: 8px;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
.sidebar::-webkit-scrollbar-track {
|
|
1369
|
+
background: transparent;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
.sidebar::-webkit-scrollbar-thumb {
|
|
1373
|
+
background: transparent;
|
|
1374
|
+
border-radius: 4px;
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
.sidebar:hover::-webkit-scrollbar-thumb {
|
|
1378
|
+
background: var(--border);
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
.sidebar-overlay {
|
|
1382
|
+
display: none;
|
|
971
1383
|
}
|
|
972
1384
|
|
|
973
1385
|
.sidebar-nav {
|
|
@@ -977,69 +1389,138 @@ body {
|
|
|
977
1389
|
}
|
|
978
1390
|
|
|
979
1391
|
.nav-item {
|
|
980
|
-
margin:
|
|
1392
|
+
margin: 1px 0;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
.sidebar-nav[data-level="0"] > .nav-item.folder:not(:first-child) {
|
|
1396
|
+
margin-top: 14px;
|
|
981
1397
|
}
|
|
982
1398
|
|
|
983
1399
|
.nav-link {
|
|
984
1400
|
display: block;
|
|
985
|
-
padding: 6px
|
|
1401
|
+
padding: 6px 8px 6px 28px;
|
|
986
1402
|
color: var(--text-muted);
|
|
987
1403
|
text-decoration: none;
|
|
988
1404
|
border-radius: 6px;
|
|
989
1405
|
font-size: 14px;
|
|
1406
|
+
line-height: 1.45;
|
|
1407
|
+
transition: background 0.12s ease, color 0.12s ease;
|
|
990
1408
|
}
|
|
991
1409
|
|
|
992
1410
|
.nav-link:hover {
|
|
993
|
-
background: var(--
|
|
1411
|
+
background: color-mix(in srgb, var(--text) 6%, transparent);
|
|
994
1412
|
color: var(--text);
|
|
995
1413
|
}
|
|
996
1414
|
|
|
997
|
-
.nav-link
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
.nav-children {
|
|
1003
|
-
margin-left: 14px;
|
|
1004
|
-
border-left: 1px solid var(--border);
|
|
1005
|
-
padding-left: 0;
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
.nav-children[data-expanded="false"] {
|
|
1009
|
-
display: none;
|
|
1415
|
+
.nav-link:focus-visible {
|
|
1416
|
+
outline: 2px solid var(--accent);
|
|
1417
|
+
outline-offset: -2px;
|
|
1010
1418
|
}
|
|
1011
1419
|
|
|
1012
1420
|
.nav-item-header {
|
|
1013
1421
|
display: flex;
|
|
1014
1422
|
align-items: center;
|
|
1015
|
-
|
|
1423
|
+
padding: 0 4px 0 2px;
|
|
1424
|
+
border-radius: 6px;
|
|
1016
1425
|
cursor: pointer;
|
|
1426
|
+
transition: background 0.12s ease;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
.nav-item-header:hover {
|
|
1430
|
+
background: color-mix(in srgb, var(--text) 6%, transparent);
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
.nav-item-header .nav-link {
|
|
1434
|
+
flex: 1;
|
|
1435
|
+
min-width: 0;
|
|
1436
|
+
padding: 6px 4px 6px 6px;
|
|
1437
|
+
color: var(--text);
|
|
1438
|
+
font-weight: 500;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
.nav-item-header .nav-link:hover {
|
|
1442
|
+
background: none;
|
|
1017
1443
|
}
|
|
1018
1444
|
|
|
1019
1445
|
.nav-toggle {
|
|
1020
|
-
|
|
1446
|
+
width: 20px;
|
|
1447
|
+
height: 20px;
|
|
1448
|
+
padding: 0;
|
|
1021
1449
|
background: none;
|
|
1022
1450
|
border: none;
|
|
1023
1451
|
cursor: pointer;
|
|
1024
|
-
padding: 4px;
|
|
1025
1452
|
color: var(--text-muted);
|
|
1026
1453
|
display: flex;
|
|
1027
1454
|
align-items: center;
|
|
1455
|
+
justify-content: center;
|
|
1028
1456
|
flex-shrink: 0;
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
.nav-toggle svg {
|
|
1032
|
-
transition: transform 0.2s;
|
|
1457
|
+
border-radius: 4px;
|
|
1033
1458
|
}
|
|
1034
1459
|
|
|
1035
1460
|
.nav-toggle:hover {
|
|
1036
1461
|
color: var(--text);
|
|
1037
1462
|
}
|
|
1038
1463
|
|
|
1464
|
+
.nav-toggle svg {
|
|
1465
|
+
transition: transform 0.2s ease;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1039
1468
|
.nav-item-header[data-expanded="true"] .nav-toggle svg {
|
|
1040
1469
|
transform: rotate(90deg);
|
|
1041
1470
|
}
|
|
1042
1471
|
|
|
1472
|
+
.nav-item.active > .nav-link {
|
|
1473
|
+
color: var(--accent);
|
|
1474
|
+
background: var(--bg);
|
|
1475
|
+
background: color-mix(in srgb, var(--accent) 12%, transparent);
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
.nav-item.active > .nav-item-header {
|
|
1479
|
+
background: var(--bg);
|
|
1480
|
+
background: color-mix(in srgb, var(--accent) 12%, transparent);
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
.nav-item.active > .nav-item-header .nav-link {
|
|
1484
|
+
color: var(--accent);
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
.nav-item.active > .nav-item-header .nav-toggle {
|
|
1488
|
+
color: var(--accent);
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
/* A section that merely contains the active page marks itself with
|
|
1492
|
+
accent text only; the pill belongs to the actual page. */
|
|
1493
|
+
.nav-item.has-active-child > .nav-item-header {
|
|
1494
|
+
background: transparent;
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
.nav-item.has-active-child > .nav-item-header:hover {
|
|
1498
|
+
background: color-mix(in srgb, var(--text) 6%, transparent);
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
.nav-item.has-active-child > .nav-item-header .nav-link {
|
|
1502
|
+
font-weight: 500;
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
.nav-children {
|
|
1506
|
+
margin-left: 12px;
|
|
1507
|
+
padding-left: 10px;
|
|
1508
|
+
border-left: 1px solid var(--border);
|
|
1509
|
+
display: grid;
|
|
1510
|
+
grid-template-rows: 1fr;
|
|
1511
|
+
transition: grid-template-rows 0.2s ease, visibility 0.2s;
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
.nav-children > .sidebar-nav {
|
|
1515
|
+
overflow: hidden;
|
|
1516
|
+
min-height: 0;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
.nav-children[data-expanded="false"] {
|
|
1520
|
+
grid-template-rows: 0fr;
|
|
1521
|
+
visibility: hidden;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1043
1524
|
|
|
1044
1525
|
.content {
|
|
1045
1526
|
flex: 1;
|
|
@@ -1073,7 +1554,7 @@ body {
|
|
|
1073
1554
|
padding: 32px 24px;
|
|
1074
1555
|
position: fixed;
|
|
1075
1556
|
right: 0;
|
|
1076
|
-
top:
|
|
1557
|
+
top: var(--header-height);
|
|
1077
1558
|
bottom: 0;
|
|
1078
1559
|
overflow-y: auto;
|
|
1079
1560
|
}
|
|
@@ -1195,7 +1676,7 @@ body {
|
|
|
1195
1676
|
.markdown-body code {
|
|
1196
1677
|
font-family: ${settings.appearance.fontFamily.code || "'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace"};
|
|
1197
1678
|
padding: 0.2em 0.4em;
|
|
1198
|
-
background: var(--code-bg);
|
|
1679
|
+
background: var(--code-inline-bg, var(--code-bg));
|
|
1199
1680
|
border-radius: 6px;
|
|
1200
1681
|
}
|
|
1201
1682
|
.markdown-body pre {
|
|
@@ -1211,6 +1692,22 @@ body {
|
|
|
1211
1692
|
padding: 0;
|
|
1212
1693
|
border-radius: 0;
|
|
1213
1694
|
}
|
|
1695
|
+
.callout,
|
|
1696
|
+
.quiz-explanation,
|
|
1697
|
+
.quiz-model-answer,
|
|
1698
|
+
.quiz-option.correct,
|
|
1699
|
+
.quiz-option.incorrect,
|
|
1700
|
+
.quiz-error {
|
|
1701
|
+
--code-inline-bg: rgba(175, 184, 193, 0.4);
|
|
1702
|
+
}
|
|
1703
|
+
[data-theme="dark"] .callout,
|
|
1704
|
+
[data-theme="dark"] .quiz-explanation,
|
|
1705
|
+
[data-theme="dark"] .quiz-model-answer,
|
|
1706
|
+
[data-theme="dark"] .quiz-option.correct,
|
|
1707
|
+
[data-theme="dark"] .quiz-option.incorrect,
|
|
1708
|
+
[data-theme="dark"] .quiz-error {
|
|
1709
|
+
--code-inline-bg: rgba(110, 118, 129, 0.4);
|
|
1710
|
+
}
|
|
1214
1711
|
|
|
1215
1712
|
/* Code block wrapper */
|
|
1216
1713
|
.code-block-wrapper {
|
|
@@ -1822,6 +2319,180 @@ body {
|
|
|
1822
2319
|
padding: 16px;
|
|
1823
2320
|
}
|
|
1824
2321
|
|
|
2322
|
+
/* Quiz */
|
|
2323
|
+
.quiz {
|
|
2324
|
+
border: 1px solid var(--border);
|
|
2325
|
+
border-radius: 6px;
|
|
2326
|
+
background: var(--bg-secondary);
|
|
2327
|
+
padding: 16px;
|
|
2328
|
+
margin-bottom: 16px;
|
|
2329
|
+
}
|
|
2330
|
+
.quiz-header {
|
|
2331
|
+
display: flex;
|
|
2332
|
+
justify-content: space-between;
|
|
2333
|
+
align-items: center;
|
|
2334
|
+
gap: 12px;
|
|
2335
|
+
margin-bottom: 8px;
|
|
2336
|
+
}
|
|
2337
|
+
.quiz-title {
|
|
2338
|
+
font-weight: 600;
|
|
2339
|
+
}
|
|
2340
|
+
.quiz-progress {
|
|
2341
|
+
font-size: 13px;
|
|
2342
|
+
color: var(--text-muted);
|
|
2343
|
+
white-space: nowrap;
|
|
2344
|
+
}
|
|
2345
|
+
.quiz-question {
|
|
2346
|
+
padding: 12px 0;
|
|
2347
|
+
border-top: 1px solid var(--border);
|
|
2348
|
+
}
|
|
2349
|
+
.quiz-question-text {
|
|
2350
|
+
margin-bottom: 8px;
|
|
2351
|
+
}
|
|
2352
|
+
.quiz-options {
|
|
2353
|
+
display: flex;
|
|
2354
|
+
flex-direction: column;
|
|
2355
|
+
gap: 6px;
|
|
2356
|
+
}
|
|
2357
|
+
.quiz-option {
|
|
2358
|
+
display: block;
|
|
2359
|
+
padding: 8px 12px;
|
|
2360
|
+
border: 1px solid var(--border);
|
|
2361
|
+
border-radius: 6px;
|
|
2362
|
+
background: var(--bg);
|
|
2363
|
+
cursor: pointer;
|
|
2364
|
+
}
|
|
2365
|
+
.quiz-option:hover {
|
|
2366
|
+
border-color: var(--accent);
|
|
2367
|
+
}
|
|
2368
|
+
.quiz-option input {
|
|
2369
|
+
accent-color: var(--accent);
|
|
2370
|
+
}
|
|
2371
|
+
.quiz-option.correct {
|
|
2372
|
+
border-color: #1a7f37;
|
|
2373
|
+
background: #dafbe1;
|
|
2374
|
+
}
|
|
2375
|
+
.quiz-option.incorrect {
|
|
2376
|
+
border-color: #cf222e;
|
|
2377
|
+
background: #ffebe9;
|
|
2378
|
+
}
|
|
2379
|
+
[data-theme="dark"] .quiz-option.correct {
|
|
2380
|
+
border-color: #3fb950;
|
|
2381
|
+
background: #0f2616;
|
|
2382
|
+
}
|
|
2383
|
+
[data-theme="dark"] .quiz-option.incorrect {
|
|
2384
|
+
border-color: #f85149;
|
|
2385
|
+
background: #3c0e0e;
|
|
2386
|
+
}
|
|
2387
|
+
.quiz-question.graded .quiz-option {
|
|
2388
|
+
cursor: default;
|
|
2389
|
+
}
|
|
2390
|
+
.quiz-question.graded .quiz-option:hover {
|
|
2391
|
+
border-color: var(--border);
|
|
2392
|
+
}
|
|
2393
|
+
.quiz-question.graded .quiz-option.correct:hover {
|
|
2394
|
+
border-color: #1a7f37;
|
|
2395
|
+
}
|
|
2396
|
+
.quiz-question.graded .quiz-option.incorrect:hover {
|
|
2397
|
+
border-color: #cf222e;
|
|
2398
|
+
}
|
|
2399
|
+
[data-theme="dark"] .quiz-question.graded .quiz-option.correct:hover {
|
|
2400
|
+
border-color: #3fb950;
|
|
2401
|
+
}
|
|
2402
|
+
[data-theme="dark"] .quiz-question.graded .quiz-option.incorrect:hover {
|
|
2403
|
+
border-color: #f85149;
|
|
2404
|
+
}
|
|
2405
|
+
.quiz-explanation,
|
|
2406
|
+
.quiz-model-answer {
|
|
2407
|
+
border-left: 4px solid #0969da;
|
|
2408
|
+
background: #ddf4ff;
|
|
2409
|
+
border-radius: 4px;
|
|
2410
|
+
padding: 10px 14px;
|
|
2411
|
+
margin-top: 8px;
|
|
2412
|
+
font-size: 14px;
|
|
2413
|
+
}
|
|
2414
|
+
[data-theme="dark"] .quiz-explanation,
|
|
2415
|
+
[data-theme="dark"] .quiz-model-answer {
|
|
2416
|
+
border-color: #58a6ff;
|
|
2417
|
+
background: #0c1c38;
|
|
2418
|
+
}
|
|
2419
|
+
.quiz-practice-check,
|
|
2420
|
+
.quiz-reveal {
|
|
2421
|
+
margin-top: 8px;
|
|
2422
|
+
}
|
|
2423
|
+
.quiz-self-mark {
|
|
2424
|
+
display: flex;
|
|
2425
|
+
gap: 8px;
|
|
2426
|
+
margin-top: 8px;
|
|
2427
|
+
}
|
|
2428
|
+
.quiz-self-mark button.selected {
|
|
2429
|
+
border-color: var(--accent);
|
|
2430
|
+
color: var(--accent);
|
|
2431
|
+
font-weight: 600;
|
|
2432
|
+
}
|
|
2433
|
+
.quiz-actions {
|
|
2434
|
+
display: flex;
|
|
2435
|
+
gap: 8px;
|
|
2436
|
+
margin-top: 12px;
|
|
2437
|
+
}
|
|
2438
|
+
.quiz button {
|
|
2439
|
+
padding: 6px 14px;
|
|
2440
|
+
border: 1px solid var(--border);
|
|
2441
|
+
border-radius: 6px;
|
|
2442
|
+
background: var(--bg);
|
|
2443
|
+
color: var(--text);
|
|
2444
|
+
font-size: 14px;
|
|
2445
|
+
cursor: pointer;
|
|
2446
|
+
transition: border-color 0.15s, color 0.15s;
|
|
2447
|
+
}
|
|
2448
|
+
.quiz button:hover:not(:disabled) {
|
|
2449
|
+
border-color: var(--accent);
|
|
2450
|
+
color: var(--accent);
|
|
2451
|
+
}
|
|
2452
|
+
.quiz button:disabled {
|
|
2453
|
+
opacity: 0.6;
|
|
2454
|
+
cursor: default;
|
|
2455
|
+
}
|
|
2456
|
+
.quiz button.quiz-check {
|
|
2457
|
+
background: var(--accent);
|
|
2458
|
+
border-color: var(--accent);
|
|
2459
|
+
color: #fff;
|
|
2460
|
+
}
|
|
2461
|
+
.quiz button.quiz-check:hover:not(:disabled) {
|
|
2462
|
+
color: #fff;
|
|
2463
|
+
opacity: 0.9;
|
|
2464
|
+
}
|
|
2465
|
+
.quiz-result {
|
|
2466
|
+
margin-top: 12px;
|
|
2467
|
+
padding: 12px 16px;
|
|
2468
|
+
border: 1px solid var(--border);
|
|
2469
|
+
border-left: 4px solid var(--accent);
|
|
2470
|
+
border-radius: 6px;
|
|
2471
|
+
background: var(--bg);
|
|
2472
|
+
}
|
|
2473
|
+
.quiz-score {
|
|
2474
|
+
font-weight: 600;
|
|
2475
|
+
font-size: 16px;
|
|
2476
|
+
}
|
|
2477
|
+
.quiz-breakdown,
|
|
2478
|
+
.quiz-history {
|
|
2479
|
+
font-size: 13px;
|
|
2480
|
+
color: var(--text-muted);
|
|
2481
|
+
margin-top: 4px;
|
|
2482
|
+
}
|
|
2483
|
+
.quiz-error {
|
|
2484
|
+
border-left: 4px solid #cf222e;
|
|
2485
|
+
background: #ffebe9;
|
|
2486
|
+
}
|
|
2487
|
+
[data-theme="dark"] .quiz-error {
|
|
2488
|
+
border-color: #f85149;
|
|
2489
|
+
background: #3c0e0e;
|
|
2490
|
+
}
|
|
2491
|
+
.quiz-error strong {
|
|
2492
|
+
display: block;
|
|
2493
|
+
margin-bottom: 4px;
|
|
2494
|
+
}
|
|
2495
|
+
|
|
1825
2496
|
/* Mermaid wrapper */
|
|
1826
2497
|
.mermaid-wrapper {
|
|
1827
2498
|
display: block;
|
|
@@ -1908,6 +2579,36 @@ body {
|
|
|
1908
2579
|
.mermaid-container[data-mode="code"] .mermaid-source {
|
|
1909
2580
|
display: block;
|
|
1910
2581
|
}
|
|
2582
|
+
/* Pele-rendered diagrams resolve colors and fonts from these variables:
|
|
2583
|
+
a single server render adapts to the active theme automatically. */
|
|
2584
|
+
.pele {
|
|
2585
|
+
--pele-bg: var(--bg);
|
|
2586
|
+
--pele-fg: var(--text);
|
|
2587
|
+
--pele-fg-on-light: var(--text);
|
|
2588
|
+
--pele-muted: var(--text-muted);
|
|
2589
|
+
--pele-line: var(--text);
|
|
2590
|
+
--pele-surface: color-mix(in srgb, var(--accent) 10%, var(--bg));
|
|
2591
|
+
--pele-surface-alt: color-mix(in srgb, var(--accent) 16%, var(--bg));
|
|
2592
|
+
--pele-border: color-mix(in srgb, var(--accent) 45%, var(--border));
|
|
2593
|
+
--pele-accent: var(--accent);
|
|
2594
|
+
--pele-font: ${settings.appearance.fontFamily.body || "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif"};
|
|
2595
|
+
--pele-font-mono: ${settings.appearance.fontFamily.code || "'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace"};
|
|
2596
|
+
}
|
|
2597
|
+
[data-theme="dark"] .pele {
|
|
2598
|
+
--pele-fg-on-dark: #ffffff;
|
|
2599
|
+
}
|
|
2600
|
+
.mermaid-error {
|
|
2601
|
+
border-left: 4px solid #cf222e;
|
|
2602
|
+
background: #ffebe9;
|
|
2603
|
+
padding: 12px 16px;
|
|
2604
|
+
border-radius: 4px;
|
|
2605
|
+
text-align: left;
|
|
2606
|
+
font-size: 14px;
|
|
2607
|
+
}
|
|
2608
|
+
[data-theme="dark"] .mermaid-error {
|
|
2609
|
+
border-color: #f85149;
|
|
2610
|
+
background: #3c0e0e;
|
|
2611
|
+
}
|
|
1911
2612
|
/* Mermaid fullscreen */
|
|
1912
2613
|
.mermaid-container.fullscreen {
|
|
1913
2614
|
position: fixed;
|
|
@@ -1974,11 +2675,28 @@ body {
|
|
|
1974
2675
|
transform: translateX(-100%);
|
|
1975
2676
|
transition: transform 0.2s;
|
|
1976
2677
|
z-index: 90;
|
|
1977
|
-
box-shadow: 2px 0
|
|
2678
|
+
box-shadow: 2px 0 12px rgba(0,0,0,0.12);
|
|
1978
2679
|
}
|
|
1979
2680
|
.sidebar.open {
|
|
1980
2681
|
transform: translateX(0);
|
|
1981
2682
|
}
|
|
2683
|
+
.sidebar-overlay {
|
|
2684
|
+
display: block;
|
|
2685
|
+
position: fixed;
|
|
2686
|
+
left: 0;
|
|
2687
|
+
right: 0;
|
|
2688
|
+
top: var(--header-height);
|
|
2689
|
+
bottom: 0;
|
|
2690
|
+
background: rgba(0, 0, 0, 0.35);
|
|
2691
|
+
opacity: 0;
|
|
2692
|
+
pointer-events: none;
|
|
2693
|
+
transition: opacity 0.2s ease;
|
|
2694
|
+
z-index: 85;
|
|
2695
|
+
}
|
|
2696
|
+
.sidebar.open + .sidebar-overlay {
|
|
2697
|
+
opacity: 1;
|
|
2698
|
+
pointer-events: auto;
|
|
2699
|
+
}
|
|
1982
2700
|
.content,
|
|
1983
2701
|
.has-toc .content {
|
|
1984
2702
|
margin-left: 0;
|
|
@@ -1990,6 +2708,14 @@ body {
|
|
|
1990
2708
|
}
|
|
1991
2709
|
}
|
|
1992
2710
|
|
|
2711
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2712
|
+
.nav-children, .nav-toggle svg, .nav-link, .nav-item-header,
|
|
2713
|
+
.site-logo-name, .sidebar, .sidebar-overlay, .content,
|
|
2714
|
+
.search-trigger, .theme-toggle, .view-toggle, .sidebar-toggle {
|
|
2715
|
+
transition: none;
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
|
|
1993
2719
|
/* Theme icons */
|
|
1994
2720
|
:root[data-theme="light"] .theme-icon-dark,
|
|
1995
2721
|
:root[data-theme="dark"] .theme-icon-light {
|