Skip to content

fix: render email address in table footnote links - #593

Open
SomSamantray wants to merge 1 commit into
charmbracelet:mainfrom
SomSamantray:fix/mailto-table-footnote-links
Open

fix: render email address in table footnote links#593
SomSamantray wants to merge 1 commit into
charmbracelet:mainfrom
SomSamantray:fix/mailto-table-footnote-links

Conversation

@SomSamantray

Copy link
Copy Markdown

Summary

linkDomain(href) built the footnote label for links inside table cells via url.Parse(href).Hostname(). 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 whenever an email autolink appears in a table cell. Reported in charmbracelet/glow#783.

This special-cases the mailto scheme and uses the parsed Opaque part (the email address) instead of Hostname(). Every other scheme is unaffected.

Changes

  • ansi/table_links.go: linkDomain now returns uri.Opaque for mailto: URIs.
  • testdata/issues/783.md (new): reproduction fixture using the exact table from the issue report, picked up automatically by the existing TestRendererIssues issue-fixture convention.
  • ansi/testdata/TestRendererIssues/783.golden (new, via go 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-mailto rendering.

go test ./... passes with no regressions.

Fixes charmbracelet/glow#783

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Email Addresses Display Incorrectly

1 participant