diff --git a/site/internal/explain/explain.go b/site/internal/explain/explain.go
index b17424d..cfe3df0 100644
--- a/site/internal/explain/explain.go
+++ b/site/internal/explain/explain.go
@@ -104,7 +104,8 @@ How to explain:
- Justify correctness informally but convincingly, especially for greedy choices.
- If they describe what they are stuck on, or include their attempt, address that directly: say what in their attempt is on the right track and where it goes wrong. Do not rewrite their code.
- Never give a complete solution in any real programming language. The sketch is short pseudocode for the core idea only.
-- Write in plain, direct prose. Use markdown for emphasis, lists and inline code. Use $...$ only if the problem statement does.
+- Write in plain, direct prose. Use markdown for emphasis, lists and inline code.
+- Write math as LaTeX, which the page typesets with KaTeX: $...$ inline, and $$...$$ on lines of its own for a formula worth displaying, such as a recurrence or an identity the approach rests on. That covers formulas, bounds, complexities and indexed sums (write $O(n \log n)$ and $\sum_{i=L}^{R} d_i$, not O(n log n) or Σ_{i=L..R} d[i]). Keep inline code for code: variable names, array accesses and expressions as they would appear in a program.
Diagram rules for each walkthrough step's svg:
- Show the actual mechanism on a small concrete example (the sample if it is small enough): array cells with index labels and pointer arrows, grid cells with their values and the current frontier, a DP table filling in, a graph with visited nodes and the edge being relaxed, a stack or heap's contents. Successive steps should show the state changing.
diff --git a/site/internal/review/review.go b/site/internal/review/review.go
index ac585e6..d536948 100644
--- a/site/internal/review/review.go
+++ b/site/internal/review/review.go
@@ -143,7 +143,7 @@ Judging delivery:
Scores, each 1 to 5: 1 missing or wrong, 2 weak, 3 adequate, 4 good, 5 what a strong candidate would do. Most decent attempts land at 3 or 4; give 5 only when nothing meaningful could be better.
-Be direct and specific. Praise only what earned it, and make every improvement something they could act on in the next recording. Write in plain, direct prose, using markdown for emphasis, lists and inline code.`
+Be direct and specific. Praise only what earned it, and make every improvement something they could act on in the next recording. Write in plain, direct prose, using markdown for emphasis, lists and inline code, and LaTeX between $...$ for math such as complexities ($O(n \log n)$); the page typesets it with KaTeX.`
// Prompt is the user message.
func Prompt(in Input) string {
diff --git a/site/web/package-lock.json b/site/web/package-lock.json
index 7ac1c5e..82bcdb4 100644
--- a/site/web/package-lock.json
+++ b/site/web/package-lock.json
@@ -8,8 +8,10 @@
"name": "usaco-site-web",
"version": "0.0.0",
"dependencies": {
+ "@vscode/markdown-it-katex": "^1.1.2",
"dompurify": "^3.4.17",
"highlight.js": "^11.11.1",
+ "katex": "^0.16.25",
"markdown-it": "^14.1.0",
"vue": "^3.5.22",
"vue-router": "^4.6.3"
@@ -1292,6 +1294,15 @@
"vue": "^3.2.25 || ^3.6.0-rc.10"
}
},
+ "node_modules/@vscode/markdown-it-katex": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@vscode/markdown-it-katex/-/markdown-it-katex-1.1.2.tgz",
+ "integrity": "sha512-+4IIv5PgrmhKvW/3LpkpkGg257OViEhXkOOgCyj5KMsjsOfnRXkni8XAuuF9Ui5p3B8WnUovlDXAQNb8RJ/RaQ==",
+ "license": "MIT",
+ "dependencies": {
+ "katex": "^0.16.4"
+ }
+ },
"node_modules/@vue/compiler-core": {
"version": "3.5.44",
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.44.tgz",
@@ -1414,6 +1425,15 @@
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"license": "Python-2.0"
},
+ "node_modules/commander": {
+ "version": "8.3.0",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz",
+ "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 12"
+ }
+ },
"node_modules/csstype": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
@@ -1572,6 +1592,22 @@
"jiti": "lib/jiti-cli.mjs"
}
},
+ "node_modules/katex": {
+ "version": "0.16.25",
+ "resolved": "https://registry.npmjs.org/katex/-/katex-0.16.25.tgz",
+ "integrity": "sha512-woHRUZ/iF23GBP1dkDQMh1QBad9dmr8/PAwNA54VrSOVYgI12MAcE14TqnDdQOdzyEonGzMepYnqBMYdsoAr8Q==",
+ "funding": [
+ "https://opencollective.com/katex",
+ "https://github.com/sponsors/katex"
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "commander": "^8.3.0"
+ },
+ "bin": {
+ "katex": "cli.js"
+ }
+ },
"node_modules/lightningcss": {
"version": "1.32.0",
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz",
diff --git a/site/web/package.json b/site/web/package.json
index 88d266e..c6a295f 100644
--- a/site/web/package.json
+++ b/site/web/package.json
@@ -12,8 +12,10 @@
"preview": "vite preview"
},
"dependencies": {
+ "@vscode/markdown-it-katex": "^1.1.2",
"dompurify": "^3.4.17",
"highlight.js": "^11.11.1",
+ "katex": "^0.16.25",
"markdown-it": "^14.1.0",
"vue": "^3.5.22",
"vue-router": "^4.6.3"
diff --git a/site/web/src/App.vue b/site/web/src/App.vue
index 1881594..c9e8b50 100644
--- a/site/web/src/App.vue
+++ b/site/web/src/App.vue
@@ -49,11 +49,13 @@ import { RouterLink, RouterView } from "vue-router";
}
nav {
display: flex;
- gap: 20px;
+ flex-wrap: wrap;
+ gap: 4px 20px;
}
nav a {
color: var(--color-ink-muted);
text-decoration: none;
+ white-space: nowrap;
}
nav a:hover,
nav a.on {
diff --git a/site/web/src/assets/styles.css b/site/web/src/assets/styles.css
index b6a2d43..3fb08e2 100644
--- a/site/web/src/assets/styles.css
+++ b/site/web/src/assets/styles.css
@@ -80,6 +80,13 @@ a {
color: var(--color-ink-link);
}
+/* Preflight leaves focus to the browser default, which is faint on the
+ paper background; keyboard users get a clear ring everywhere. */
+:focus-visible {
+ outline: 2px solid var(--color-ink-link);
+ outline-offset: 2px;
+}
+
.card {
background: var(--color-paper);
border: 1px solid var(--color-line-soft);
diff --git a/site/web/src/components/CodeBlock.vue b/site/web/src/components/CodeBlock.vue
index e05225e..a6f492a 100644
--- a/site/web/src/components/CodeBlock.vue
+++ b/site/web/src/components/CodeBlock.vue
@@ -8,10 +8,12 @@ import { computed, ref } from "vue";
import hljs from "highlight.js/lib/core";
import cpp from "highlight.js/lib/languages/cpp";
import python from "highlight.js/lib/languages/python";
+import rust from "highlight.js/lib/languages/rust";
hljs.registerLanguage("cpp", cpp);
hljs.registerLanguage("c", cpp);
hljs.registerLanguage("python", python);
+hljs.registerLanguage("rust", rust);
const props = defineProps({
content: { type: String, required: true },
diff --git a/site/web/src/components/Explanation.vue b/site/web/src/components/Explanation.vue
index c00ddfd..7f032bd 100644
--- a/site/web/src/components/Explanation.vue
+++ b/site/web/src/components/Explanation.vue
@@ -6,14 +6,15 @@
* section (who wrote it, when) stays visible. Reviews use it too, with the
* sections worth reading at once named in open.
*
- * Markdown is rendered with html: false like the notes. The one exception
- * is ```svg fences, the walkthrough's diagrams: they are inserted as SVG
- * after DOMPurify's SVG profile has stripped scripts, event handlers and
+ * Markdown is rendered like the notes (@/markdown: no raw HTML, KaTeX for
+ * math). The one exception is ```svg fences, the walkthrough's diagrams:
+ * they are inserted as SVG after DOMPurify's SVG profile has stripped
+ * scripts, event handlers and
* anything else that is not drawing. Claude wrote them, the admin can edit
* them, and the public sees them once the problem is solved.
*/
import { computed } from "vue";
-import MarkdownIt from "markdown-it";
+import { markdown } from "@/markdown";
import DOMPurify from "dompurify";
const props = defineProps({
@@ -21,7 +22,7 @@ const props = defineProps({
open: { type: Array, default: () => [] },
});
-const md = new MarkdownIt({ html: false, linkify: true });
+const md = markdown();
const fence = md.renderer.rules.fence;
md.renderer.rules.fence = (tokens, idx, options, env, self) => {
const t = tokens[idx];
diff --git a/site/web/src/markdown.js b/site/web/src/markdown.js
new file mode 100644
index 0000000..5e74e3b
--- /dev/null
+++ b/site/web/src/markdown.js
@@ -0,0 +1,19 @@
+/**
+ * The one markdown setup every view renders with: notes, statements,
+ * explanations and reviews.
+ *
+ * html: false — markdown only, never raw HTML. Math is the exception that
+ * proves it: $…$, $$…$$ and ```math fences are typeset by KaTeX, whose
+ * output is its own markup and which refuses \href, \htmlClass and the like
+ * unless told to trust the source (it isn't). Explanations are asked to use
+ * $…$ when the statement does (internal/explain). A formula KaTeX can't
+ * parse is shown as its source in red rather than breaking the page.
+ */
+
+import MarkdownIt from "markdown-it";
+import katex from "@vscode/markdown-it-katex";
+import "katex/dist/katex.min.css";
+
+export function markdown() {
+ return new MarkdownIt({ html: false, linkify: true }).use(katex, { throwOnError: false, enableFencedBlocks: true });
+}
diff --git a/site/web/src/views/ProblemList.vue b/site/web/src/views/ProblemList.vue
index c265105..c0ccdc3 100644
--- a/site/web/src/views/ProblemList.vue
+++ b/site/web/src/views/ProblemList.vue
@@ -49,8 +49,9 @@ const counts = computed(() => {
return c;
});
+// An empty tab is left out unless it is the one selected (a linked view).
const tabs = computed(() =>
- admin.value ? ["all", "solving", "solved", "skipped"] : [],
+ admin.value ? ["all", "solving", "solved", "skipped"].filter((t) => counts.value[t] || status.value === t) : [],
);
// When a problem was last worked on, for sorting: the solve date if it has
@@ -67,6 +68,22 @@ const shown = computed(() => {
if (sort.value === "name") return list.sort((a, b) => a.name.localeCompare(b.name));
return list.sort((a, b) => when(b).localeCompare(when(a)) || a.name.localeCompare(b.name));
});
+
+// Most recent is split by month, so a long list has landmarks; by name it
+// is one block. An undated problem sorts last, under "Undated".
+const groups = computed(() => {
+ if (sort.value === "name") return [{ key: "all", label: "", items: shown.value }];
+ const out = [];
+ for (const p of shown.value) {
+ const w = when(p);
+ const key = w ? w.slice(0, 7) : "none";
+ if (out.at(-1)?.key !== key) {
+ out.push({ key, label: w ? formatDate(w, { month: "long", year: "numeric" }) : "Undated", items: [] });
+ }
+ out.at(-1).items.push(p);
+ }
+ return out;
+});
@@ -99,26 +116,34 @@ const shown = computed(() => {
{{ error }} Nothing matches.
-
+ {{ g.label }} {{ g.items.length }}
+
+
+
+ Claude writes an intuitive explanation with diagrams, laid out as hints you open one at a time. It takes a
+ minute or two and is committed as explain.md.
+
+ Record yourself explaining your solution as you would to an interviewer, then upload it (mp3, m4a, wav,
+ webm, ogg or flac, up to 25 MB). It is transcribed, and Claude gives feedback on the approach and on your
+ delivery. Each review is committed under reviews/.
+
{{ editError }}
- - -
- Claude writes an intuitive explanation with diagrams, laid out as hints you open one at a time. It takes a
- minute or two and is committed as explain.md.
-
{{ job.error }}
-
- Record yourself explaining your solution as you would to an interviewer, then upload it (mp3, m4a, wav,
- webm, ogg or flac, up to 25 MB). It is transcribed, and Claude gives feedback on the approach and on your
- delivery. Each review is committed under reviews/.
-
{{ reviewJob.error }}
+Explain: {{ job.error }}
+Review: {{ reviewJob.error }}