From 065e9383d0d44825689ecb637154c067ac477c2a Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Thu, 9 Apr 2026 19:33:08 -0700 Subject: [PATCH 1/3] fix: use proper link text in markdown dump for block-content anchors When an anchor wraps block content (divs, images), the markdown dump produced `([](url))` with empty display text. This is not valid markdown and provides no useful information to LLMs consuming the output. Now uses the anchor's aria-label or title attribute as display text, falling back to the href itself. Produces `[label](url)` instead. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/browser/markdown.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/browser/markdown.zig b/src/browser/markdown.zig index 5a83dfdc..3e9f787c 100644 --- a/src/browser/markdown.zig +++ b/src/browser/markdown.zig @@ -298,9 +298,11 @@ const Context = struct { try self.renderChildren(el.asNode()); if (href) |h| { if (!self.state.last_char_was_newline) try self.writer.writeByte('\n'); - try self.writer.writeAll("([]("); + try self.writer.writeByte('['); + try self.writer.writeAll(label orelse h); + try self.writer.writeAll("]("); try self.writer.writeAll(h); - try self.writer.writeAll("))\n"); + try self.writer.writeAll(")\n"); self.state.last_char_was_newline = true; } return; From 5cc49e79b8029c0d5a1bf50e0e3333f741ab27d3 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Thu, 9 Apr 2026 20:49:39 -0700 Subject: [PATCH 2/3] fix: update block link test to match new link text format The "browser.markdown: block link" test expected the old format ([](url)). Updated to expect [url](url) since block-content anchors without aria-label/title now use the href as display text. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/browser/markdown.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/markdown.zig b/src/browser/markdown.zig index 3e9f787c..7107b449 100644 --- a/src/browser/markdown.zig +++ b/src/browser/markdown.zig @@ -589,7 +589,7 @@ test "browser.markdown: block link" { \\### Title \\ \\Description - \\([](https://example.com)) + \\[https://example.com](https://example.com) \\ ); } From c1a65160c17c7033d9ff17bf2c7e413dcd5ea716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= Date: Fri, 10 Apr 2026 16:14:58 +0200 Subject: [PATCH 3/3] markdown: test block link aria-label and title handling --- src/browser/markdown.zig | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/browser/markdown.zig b/src/browser/markdown.zig index 7107b449..8a2f1031 100644 --- a/src/browser/markdown.zig +++ b/src/browser/markdown.zig @@ -594,6 +594,38 @@ test "browser.markdown: block link" { ); } +test "browser.markdown: block link with aria-label" { + try testMarkdownHTML( + \\ + \\

Title

+ \\

Description

+ \\
+ , + \\ + \\### Title + \\ + \\Description + \\[Docs](https://example.com) + \\ + ); +} + +test "browser.markdown: block link with title" { + try testMarkdownHTML( + \\ + \\

Title

+ \\

Description

+ \\
+ , + \\ + \\### Title + \\ + \\Description + \\[Docs](https://example.com) + \\ + ); +} + test "browser.markdown: inline link" { try testMarkdownHTML( \\

Visit Example.