fix: render email address in table footnote links - #593
Open
SomSamantray wants to merge 1 commit into
Open
Conversation
linkDomain used url.Parse(href).Hostname() to build the footnote label for links inside table cells. mailto: URIs are opaque (no "//host"), so Hostname() always returns "" for them -- producing a blank in-cell marker and a footnote line with no visible address for email autolinks in tables. Special-case the mailto scheme and use the parsed Opaque part (the email address) instead. Non-mailto links/images are unaffected. Fixes charmbracelet/glow#783
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.
Summary
linkDomain(href)built the footnote label for links inside table cells viaurl.Parse(href).Hostname().mailto:URIs are opaque (no//host), soHostname()always returns""for them -- producing a blank in-cell marker and a footnote line with no visible address whenever an email autolink appears in a table cell. Reported in charmbracelet/glow#783.This special-cases the
mailtoscheme and uses the parsedOpaquepart (the email address) instead ofHostname(). Every other scheme is unaffected.Changes
ansi/table_links.go:linkDomainnow returnsuri.Opaqueformailto:URIs.testdata/issues/783.md(new): reproduction fixture using the exact table from the issue report, picked up automatically by the existingTestRendererIssuesissue-fixture convention.ansi/testdata/TestRendererIssues/783.golden(new, viago test ./ansi/... -update): golden output showing both email addresses now render, in-cell and in the footnote list.Verification
Before/after diff on the golden output confirms the fix: pre-fix, the in-cell hyperlink had no visible text (
Foo Bar ]8;...mailto:foo@bar.org]8;;-- blank between the hyperlink open/close); post-fix it shows the address (...foo@bar.orgfoo@bar.org]8;;).Existing fixtures with non-email links/images in tables (
table_with_footer_links.md,table_with_footer_images.md) still golden-match unchanged, so this doesn't affect non-mailtorendering.go test ./...passes with no regressions.Fixes charmbracelet/glow#783