From d21b0790a6c146815f28fea604e41e922f009590 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Sun, 11 Oct 2026 02:27:08 -0700 Subject: [PATCH] fix(ui): render formatting inside markdown link labels (#54451) --- packages/ui/src/context/marked-base.tsx | 4 ++-- packages/ui/src/context/marked-parser.test.ts | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/ui/src/context/marked-base.tsx b/packages/ui/src/context/marked-base.tsx index 0ffb547adeb..b51ce5ea72c 100644 --- a/packages/ui/src/context/marked-base.tsx +++ b/packages/ui/src/context/marked-base.tsx @@ -3,10 +3,10 @@ import { Marked } from "marked" export function createMarkdownBase() { return new Marked({ renderer: { - link({ href, title, text }) { + link({ href, title, tokens }) { const titleAttr = title ? ` title="${title}"` : "" - return `${text}` + return `${this.parser.parseInline(tokens)}` }, }, }) diff --git a/packages/ui/src/context/marked-parser.test.ts b/packages/ui/src/context/marked-parser.test.ts index 1b7ac3b9c34..30093e45726 100644 --- a/packages/ui/src/context/marked-parser.test.ts +++ b/packages/ui/src/context/marked-parser.test.ts @@ -4,10 +4,18 @@ import { parseSmallMarkdown } from "./marked-base" const parser = createMarkdownParser((code, language) => `
${code}
`) -test("renders links with application attributes", async () => { - expect(await parser.parse("[OpenCode](https://opencode.ai)")).toBe( - '

OpenCode

\n', - ) +test.each([ + ["OpenCode", "OpenCode"], + ["**`#123`**", "#123"], + ["*Review* ~~draft~~", "Review draft"], + ["``", "<example>"], + ["\\*literal\\*", "*literal*"], +])("renders link label %s with application attributes", async (label, html) => { + const markdown = `[${label}](https://opencode.ai)` + const expected = `

${html}

\n` + + expect(await parser.parse(markdown)).toBe(expected) + expect(parseSmallMarkdown(markdown)).toBe(expected) }) test("renders inline and block math", async () => {