Files
DeepTutor/web/tests/reading-web-markdown.test.ts
Rimcat-JA f75d44eb03 fix(reading): render uploaded Markdown files, including math
Uploaded .md / .markdown files were stored as plain_text, so immersive
reading showed their literal source and every formula stayed raw LaTeX.
Record them as web_markdown so they take the existing safe rich renderer
(KaTeX, no raw HTML). Images stay off for uploads, since their links can
point at any host; web snapshots keep their localized images.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 14:12:08 +09:00

24 lines
858 B
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
test("web snapshots and uploaded Markdown use the safe rich Markdown renderer", () => {
const reader = fs.readFileSync(
path.join(process.cwd(), "components/reading/TextUnitView.tsx"),
"utf8",
);
const pane = fs.readFileSync(
path.join(process.cwd(), "components/reading/ReaderPane.tsx"),
"utf8",
);
assert.match(reader, /contentFormat === "web_markdown"/);
assert.match(reader, /<RichMarkdownRenderer/);
assert.match(reader, /allowHtml=\{false\}/);
assert.match(reader, /enableImages=\{sourceType !== "upload"\}/);
assert.match(reader, /whitespace-pre-wrap/);
assert.match(pane, /contentFormat=\{material\.content_format\}/);
assert.match(pane, /sourceType=\{material\.source_type\}/);
});