diff --git a/packages/ui/src/context/marked-base.tsx b/packages/ui/src/context/marked-base.tsx index 0ffb547adebd..b51ce5ea72cf 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 1b7ac3b9c341..30093e45726f 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(
- '\n',
- )
+test.each([
+ ["OpenCode", "OpenCode"],
+ ["**`#123`**", "#123"],
+ ["*Review* ~~draft~~", "Review <example>"],
+ ["\\*literal\\*", "*literal*"],
+])("renders link label %s with application attributes", async (label, html) => {
+ const markdown = `[${label}](https://opencode.ai)`
+ const expected = `\n`
+
+ expect(await parser.parse(markdown)).toBe(expected)
+ expect(parseSmallMarkdown(markdown)).toBe(expected)
})
test("renders inline and block math", async () => {