Skip to content

fix: preserve markdown hyperlink targets#1058

Open
kitlangton wants to merge 15 commits into
anomalyco:mainfrom
kitlangton:markdown-link-hyperlink-fix-pr
Open

fix: preserve markdown hyperlink targets#1058
kitlangton wants to merge 15 commits into
anomalyco:mainfrom
kitlangton:markdown-link-hyperlink-fix-pr

Conversation

@kitlangton
Copy link
Copy Markdown
Collaborator

@kitlangton kitlangton commented May 13, 2026

Summary

  • Hide Markdown link destinations in conceal mode while keeping visible labels clickable through OSC 8 hyperlink metadata.
  • Detect and style visible bare URLs without hyperlinking URLs inside Markdown code spans.
  • Preserve distinct markup.link.label and markup.link.url styling.
  • Keep generated native chunk styles isolated across live buffers and release transient registrations as buffers/content change.

Before

Check out OpenTUI (https://github.com/sst/opentui) for more.

After

Check out OpenTUI for more.

The displayed OpenTUI label retains its label style and carries the hidden https://github.com/sst/opentui OSC 8 target.

Simplify Review

  • Removed the added renderer hyperlink override configuration and TypeScript FFI wiring; terminal capability detection remains the existing source of truth.
  • Removed the redundant explicit Markdown-link regex scan; parser URL ranges now walk across intervening conceal highlights to associate labels.
  • Limited bare-URL fallback so inline/fenced raw Markdown content is not linkified and parser-provided URL ranges are not duplicated.
  • Restored protection for one-character conceal replacements so an entity before a link cannot shift link-range mapping.
  • Avoided restyling clickable label text with URL colors when label and URL theme styles differ.
  • Replaced per-buffer style registration leakage with cleanup of transient generated styles on content clear/reset, style detach, and buffer destruction.

Verification

  • bun test src/lib/detect-links.test.ts passes: 9 pass, 0 fail.
  • bun run fmt:check packages/core/src/lib/detect-links.ts packages/core/src/lib/detect-links.test.ts packages/core/src/renderables/Markdown.ts packages/core/src/renderables/__tests__/Markdown.test.ts packages/core/src/renderer.ts packages/core/src/zig.ts packages/core/src/zig/syntax-style.zig packages/core/src/zig/text-buffer.zig packages/core/src/zig/tests/text-buffer_test.zig packages/examples/src/markdown-demo.ts passes.
  • zig fmt --check packages/core/src/zig/syntax-style.zig packages/core/src/zig/text-buffer.zig packages/core/src/zig/tests/text-buffer_test.zig passes.
  • The previous CI run identified missing link metadata when a conceal range separates label and URL highlights; commit 54a8042a adds that exact regression and the one-line parser-range traversal fix.
  • Local renderer/native test execution is blocked by the local Zig linker failure already observed for current clean worktrees; CI builds the native library from source and is the authoritative native verification path.

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.

2 participants