fix(ui): render dream diary markdown

This commit is contained in:
Peter Steinberger
2026-05-04 04:25:40 +01:00
parent 143db94701
commit 6f8b9bb573
3 changed files with 27 additions and 1 deletions

View File

@@ -384,6 +384,29 @@ describe("dreaming view", () => {
setDreamSubTab("scene");
});
it("renders dream diary markdown through the sanitized markdown pipeline", () => {
setDreamSubTab("diary");
setDreamDiarySubTab("dreams");
const container = renderInto(
buildProps({
dreamDiaryContent: [
"# Dream Diary",
"",
"---",
"",
"*April 8, 2026*",
"",
"**Bold** and *italic*",
].join("\n"),
}),
);
const body = container.querySelector(".dreams-diary__para");
expect(body?.querySelector("strong")?.textContent).toBe("Bold");
expect(body?.querySelector("em")?.textContent).toBe("italic");
setDreamSubTab("scene");
});
it("flattens structured backfill diary entries into plain prose", () => {
setDreamSubTab("diary");
setDreamDiarySubTab("dreams");

View File

@@ -1,10 +1,12 @@
import { html, nothing } from "lit";
import { unsafeHTML } from "lit/directives/unsafe-html.js";
import { t } from "../../i18n/index.ts";
import type {
DreamingEntry,
WikiImportInsights,
WikiMemoryPalace,
} from "../controllers/dreaming.ts";
import { toSanitizedMarkdownHtml } from "../markdown.ts";
// ── Diary entry parser ─────────────────────────────────────────────────
@@ -1326,7 +1328,7 @@ function renderDreamDiaryEntries(props: DreamingProps) {
${flattenDiaryBody(entry.body).map(
(para, i) =>
html`<p class="dreams-diary__para" style="animation-delay: ${0.3 + i * 0.15}s;">
${para}
${unsafeHTML(toSanitizedMarkdownHtml(para))}
</p>`,
)}
</div>