From 967d9260d1fde2b992a3ae7479072fdd08cc32f2 Mon Sep 17 00:00:00 2001 From: Julian Hammer Date: Fri, 1 May 2026 16:36:47 +0100 Subject: [PATCH 1/4] wrap popup_state.text in a div for better styling and add scroll overflow to .html class --- src/components/Popup.svelte | 8 +++++++- src/routes/app.css | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/Popup.svelte b/src/components/Popup.svelte index 6dda5517..7d1d99d5 100644 --- a/src/components/Popup.svelte +++ b/src/components/Popup.svelte @@ -70,7 +70,9 @@ an issue when clicking two reasons in a row. So it's a
then. - {@html popup_state.text} +
+ {@html popup_state.text} +
@@ -119,6 +121,10 @@ an issue when clicking two reasons in a row. So it's a
then. pointer-events: initial; } + .html { + overflow-y: scroll; + } + button { padding: 0.2rem 1rem; } diff --git a/src/routes/app.css b/src/routes/app.css index a53a0fcc..5ab8cbca 100644 --- a/src/routes/app.css +++ b/src/routes/app.css @@ -296,3 +296,7 @@ label { .katex-display { margin: 0.5em 0; } + +.katex { + white-space: nowrap; +} From 275d27d1fdb6bfdbbe72b56dd3470236475be2d1 Mon Sep 17 00:00:00 2001 From: Julian Hammer Date: Fri, 1 May 2026 21:24:42 +0100 Subject: [PATCH 2/4] refactor: update .katex class to .katex-break for better text wrapping --- src/routes/app.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/app.css b/src/routes/app.css index 5ab8cbca..9a9604d3 100644 --- a/src/routes/app.css +++ b/src/routes/app.css @@ -286,7 +286,6 @@ label { } } -/* cf. https://katex.org/docs/issues */ .katex-display > .katex { white-space: normal; } @@ -297,6 +296,7 @@ label { margin: 0.5em 0; } -.katex { - white-space: nowrap; +.katex-break { + white-space: normal; + display: inline; } From a59ffbe99c73675451bf3fa0d8eed81980a0f793 Mon Sep 17 00:00:00 2001 From: Julian Hammer Date: Fri, 1 May 2026 21:27:38 +0100 Subject: [PATCH 3/4] chore: add comment referencing KaTeX documentation for clarity --- src/routes/app.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/routes/app.css b/src/routes/app.css index 9a9604d3..3fec89a8 100644 --- a/src/routes/app.css +++ b/src/routes/app.css @@ -286,6 +286,7 @@ label { } } +/* cf. https://katex.org/docs/issues */ .katex-display > .katex { white-space: normal; } From 6ae3514d9b5e704a98676cafcfebff99537e12d6 Mon Sep 17 00:00:00 2001 From: Julian Hammer Date: Sat, 2 May 2026 02:04:27 +0100 Subject: [PATCH 4/4] feat: integrate DOMPurify for HTML sanitization across components --- package.json | 1 + pnpm-lock.yaml | 20 ++++++------ src/components/Popup.svelte | 5 ++- src/components/Selection.svelte | 7 ++-- src/lib/client/sanitize_HTML.ts | 22 +++++++++++++ .../category-comparison/[...ids]/+page.svelte | 3 +- .../category-implication/[id]/+page.svelte | 3 +- .../category-property/[id]/+page.svelte | 3 +- src/routes/category/[id]/+page.svelte | 32 ++++++++++--------- src/routes/foundations/+page.svelte | 3 +- .../functor-implication/[id]/+page.svelte | 3 +- src/routes/functor-property/[id]/+page.svelte | 3 +- src/routes/functor/[id]/+page.svelte | 3 +- src/routes/lemma/[id]/+page.svelte | 5 +-- 14 files changed, 73 insertions(+), 40 deletions(-) create mode 100644 src/lib/client/sanitize_HTML.ts diff --git a/package.json b/package.json index a2dbcca4..8ac1942a 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "@fortawesome/free-solid-svg-icons": "^7.2.0", "@libsql/client": "^0.17.2", "@octokit/app": "^16.1.2", + "dompurify": "^3.4.2", "es6-crawler-detect": "^4.0.2", "ioredis": "^5.10.1", "katex": "^0.16.44", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a6a92e1f..88afb8e2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,6 +24,9 @@ importers: '@octokit/app': specifier: ^16.1.2 version: 16.1.2 + dompurify: + specifier: ^3.4.2 + version: 3.4.2 es6-crawler-detect: specifier: ^4.0.2 version: 4.0.2 @@ -649,42 +652,36 @@ packages: engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] - libc: [glibc] '@rolldown/binding-linux-arm64-musl@1.0.0-rc.12': resolution: {integrity: sha512-V6/wZztnBqlx5hJQqNWwFdxIKN0m38p8Jas+VoSfgH54HSj9tKTt1dZvG6JRHcjh6D7TvrJPWFGaY9UBVOaWPw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] - libc: [musl] '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.12': resolution: {integrity: sha512-AP3E9BpcUYliZCxa3w5Kwj9OtEVDYK6sVoUzy4vTOJsjPOgdaJZKFmN4oOlX0Wp0RPV2ETfmIra9x1xuayFB7g==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [ppc64] os: [linux] - libc: [glibc] '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.12': resolution: {integrity: sha512-nWwpvUSPkoFmZo0kQazZYOrT7J5DGOJ/+QHHzjvNlooDZED8oH82Yg67HvehPPLAg5fUff7TfWFHQS8IV1n3og==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [s390x] os: [linux] - libc: [glibc] '@rolldown/binding-linux-x64-gnu@1.0.0-rc.12': resolution: {integrity: sha512-RNrafz5bcwRy+O9e6P8Z/OCAJW/A+qtBczIqVYwTs14pf4iV1/+eKEjdOUta93q2TsT/FI0XYDP3TCky38LMAg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] - libc: [glibc] '@rolldown/binding-linux-x64-musl@1.0.0-rc.12': resolution: {integrity: sha512-Jpw/0iwoKWx3LJ2rc1yjFrj+T7iHZn2JDg1Yny1ma0luviFS4mhAIcd1LFNxK3EYu3DHWCps0ydXQ5i/rrJ2ig==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] - libc: [musl] '@rolldown/binding-openharmony-arm64@1.0.0-rc.12': resolution: {integrity: sha512-vRugONE4yMfVn0+7lUKdKvN4D5YusEiPilaoO2sgUWpCvrncvWgPMzK00ZFFJuiPgLwgFNP5eSiUlv2tfc+lpA==} @@ -866,6 +863,9 @@ packages: devalue@5.6.4: resolution: {integrity: sha512-Gp6rDldRsFh/7XuouDbxMH3Mx8GMCcgzIb1pDTvNyn8pZGQ22u+Wa+lGV9dQCltFQ7uVw0MhRyb8XDskNFOReA==} + dompurify@3.4.2: + resolution: {integrity: sha512-lHeS9SA/IKeIFFyYciHBr2n0v1VMPlSj843HdLOwjb2OxNwdq9Xykxqhk+FE42MzAdHvInbAolSE4mhahPpjXA==} + dotenv@17.3.1: resolution: {integrity: sha512-IO8C/dzEb6O3F9/twg6ZLXz164a2fhTnEWb95H23Dm4OuN+92NmEAlTrupP9VW6Jm3sO26tQlqyvyi4CsnY9GA==} engines: {node: '>=12'} @@ -991,28 +991,24 @@ packages: engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] - libc: [glibc] lightningcss-linux-arm64-musl@1.32.0: resolution: {integrity: sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==} engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] - libc: [musl] lightningcss-linux-x64-gnu@1.32.0: resolution: {integrity: sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] - libc: [glibc] lightningcss-linux-x64-musl@1.32.0: resolution: {integrity: sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] - libc: [musl] lightningcss-win32-arm64-msvc@1.32.0: resolution: {integrity: sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==} @@ -1897,6 +1893,10 @@ snapshots: devalue@5.6.4: {} + dompurify@3.4.2: + optionalDependencies: + '@types/trusted-types': 2.0.7 + dotenv@17.3.1: {} entities@4.5.0: {} diff --git a/src/components/Popup.svelte b/src/components/Popup.svelte index 7d1d99d5..c5b8c026 100644 --- a/src/components/Popup.svelte +++ b/src/components/Popup.svelte @@ -34,6 +34,7 @@ an issue when clicking two reasons in a row. So it's a
then. @@ -8,7 +9,7 @@ description="How to make sense of categories in set theory" /> -{@html data.content} +