Repository navigation
fix(table): keep link addresses in table copy and download - #786
mangeshraut712 wants to merge 4 commits into
Conversation
extractTableDataFromElement read only a cell's text, so a link lost its href in every Markdown, CSV and TSV export. Serialise a link as [text](href) alongside images, and give the link-safety button a data-href so its address can be read too. Autolinks and links still streaming in stay plain text. Fixes vercel#784
|
@mangeshraut712 is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
A literal ! immediately before [text](href) was written as an image. Escape that bang in Markdown so the link is preserved. Labels that only equal the href, such as /docs, are not autolinks, so they keep [text](href). Genuine images, URL/www/email autolinks, and CSV/TSV output are unchanged.
|
Follow-up in 6901700: a URL label with a literal space, such as https://example.com/two words, was treated as an autolink when the anchor destination contained %20. That exported only the label, so Markdown could link only the prefix before the space. Labels containing whitespace now retain explicit Markdown link syntax. The focused serializer assertion reproduced the loss at 1550965 and passed after the fix. The full Streamdown package suite passed locally on Node 24.22.0 with pnpm 10.30.3 after building the workspace dependencies: 103 files, 1,583 tests. |
✅ All commits are signedAll 4 commit(s) in this pull request have a verified signature. Thanks! Checked at 707acf6. |
6901700 to
89aa036
Compare
|
Ready for review. On the current head ( The one red status is the |
Fixes #784.
Summary
When a table is copied or downloaded from its controls, links lose their address and only the link text is kept.
extractTableDataFromElementreads each cell's text nodes, so an<a href>contributes its text and drops thehref.This PR serialises a link in a cell as
[text](href), the same way images are already exported as:[](…)round-trips.(,),|and spaces can't end the link early.tableDataToMarkdownleaves it unescaped andTableDatakeeps its shape.<button>with nohref. The button now carries the address indata-href, so these links are exported too. This was the case in the issue's repro with link safety on.https://…,www.…, or an email).streamdown:incomplete-link).This keeps the existing bare-link round-trip tests unchanged.
CSV and TSV get the same
[text](href)cell text, matching what they already get for images.Test plan
__tests__/table-links.test.tsxcovers:<Streamdown>with link safety on (the default) and off<a>withouthreflib/reverted, 6 of its 7 tests fail. The one that still passes is the plain-text case.vitest runinpackages/streamdown: 103 files, 1579 tests pass.ultracite checkis clean on the changed files.tsc --noEmitreports no new errors (the same count before and after).