Autolink bare URLs and emails in the HTML renderer - #144
Merged
Conversation
The editor styler linkifies bare URLs with NSDataDetector, but the HTML renderer emitted them as plain text, so the pasteboard's rich flavors (HTML/RTF/web archive) carried no anchor. Rich-paste consumers — Mail, Outlook — take those flavors verbatim and run no link detection of their own, so a URL that is clickable in the editor pasted as dead text. Wrap detector matches in <a href> (emails as mailto:) in the renderer's text runs, using the same system detector as the styler so in-editor and copied-out linking agree. RTF and web archive derive from that HTML and inherit the anchors. Text inside an explicit link's title renders with linkable: false so anchors never nest; code spans are their own inline node and stay excluded, matching the styler's in-code rule. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Copying a bare URL from the editor and pasting it into Mail or Outlook produced dead text. The editor styler linkifies bare URLs with
NSDataDetector, but the HTML renderer emitted them as plain text — so the pasteboard's rich flavors (HTML, RTF, web archive) carried no anchor, and rich-paste consumers take those flavors verbatim without running any link detection of their own. (Explicit[title](url)links were always fine; only bare URLs died.)Reproducer: type
https://example.comin the editor (renders clickable), select + copy, paste into Outlook/Mail → plain text instead of a hyperlink.Fix
MarkdownHTMLRenderernow wraps detector matches in<a href>(emails asmailto:) when rendering text runs, using the same system detector as the styler so in-editor and copied-out linking agree. The RTF and web-archive flavors are derived from that HTML, so all three inherit the anchor.Guards, both matching the styler's exclusions:
linkable: false, so a URL-shaped title never nests a second<a>inside the link's own.The detector is built once (per the styler's documented rebuild cost, ENG-8g1b).
Tests
&-escaped query / scheme-lesswww./ emailmailto:; autolink through bold and re-parsed blockquote content; exclusion inside code spans and link titles..htmlflavor and aHYPERLINKfield in the derived.rtf.All 317 tests pass.
🤖 Generated with Claude Code