Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/core/src/renderables/Markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,14 @@ export class MarkdownRenderable extends Renderable {
for (const child of token.tokens) {
this.renderInlineTokenWithStyle(child as MarkedToken, chunks, "markup.link.label", linkHref)
}
chunks.push(this.createChunk(" (", "markup.link", linkHref))
chunks.push(this.createChunk(token.href, "markup.link.url", linkHref))
chunks.push(this.createChunk(")", "markup.link", linkHref))
// Only show (href) suffix when label text differs from the URL itself
// (autolinks and bare URLs have label === href, so showing both is redundant)
const labelText = token.tokens.map((t: { raw: string }) => t.raw).join("")
if (labelText !== token.href) {
chunks.push(this.createChunk(" (", "markup.link", linkHref))
chunks.push(this.createChunk(token.href, "markup.link.url", linkHref))
chunks.push(this.createChunk(")", "markup.link", linkHref))
}
} else {
chunks.push(this.createChunk("[", "markup.link", linkHref))
for (const child of token.tokens) {
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/renderables/__tests__/Markdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -984,8 +984,7 @@ test("incomplete link (no closing paren)", async () => {

expect(await renderMarkdown(markdown)).toMatchInlineSnapshot(`
"
Check out [this link](https://example.com (https://example.
com)"
Check out [this link](https://example.com"
`)
})

Expand Down
Loading