diff --git a/canvas/src/markdown.test.ts b/canvas/src/markdown.test.ts index 52e83444..a408c121 100644 --- a/canvas/src/markdown.test.ts +++ b/canvas/src/markdown.test.ts @@ -15,6 +15,13 @@ describe("renderMarkdown", () => { expect(renderMarkdown("run `bun test")).toContain("bun test"); }); + it("draws no picture until its source has arrived whole", () => { + expect(renderMarkdown("see ![shot](https://x.dev/a")).not.toContain(" { expect(renderMarkdown("| a | b |")).not.toContain("` is the project's server @@ -21,6 +21,11 @@ const md = new Marked({ token.href = `file${url.pathname}${url.search}${url.hash}`; } }, + // A picture a delta cut open comes out of remend under a source only Streamdown draws, which + // DOMPurify drops, leaving an `` with none. Nothing is drawn until the rest arrives. + renderer: { + image: ({ href }) => (href === INCOMPLETE_IMAGE_PLACEHOLDER ? "" : false), + }, }); export function renderMarkdown(text: string): string {