Skip to content

Fix relative markdown link handling#5505

Merged
YourRobotOverlord merged 1 commit into
tui-cs:developfrom
YourRobotOverlord:add-relative-link-rendering
Jun 19, 2026
Merged

Fix relative markdown link handling#5505
YourRobotOverlord merged 1 commit into
tui-cs:developfrom
YourRobotOverlord:add-relative-link-rendering

Conversation

@YourRobotOverlord

Copy link
Copy Markdown
Collaborator

Summary

  • Treat relative Markdown link targets as clickable links alongside anchors and safe absolute URIs
  • Restrict OSC8 hyperlink emission to safe absolute URI schemes
  • Add regression tests for relative links in Markdown text and table cells
  • Add a relative-link example to the Markdown demo content

Fixes #5504

Testing

  • dotnet build Terminal.Gui/Terminal.Gui.csproj --no-restore
  • dotnet test --project Tests/UnitTestsParallelizable --no-restore --filter-class "*MarkdownViewTests" /p:BuildProjectReferences=false

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Markdown rendering/click handling pipeline so relative Markdown link targets behave like other clickable links (styling + LinkClicked), while keeping OSC8 hyperlink emission restricted to safe absolute URI schemes.

Changes:

  • Treat relative link targets as Markdown “link targets” for styling/clickability (underline + click events).
  • Gate OSC8 hyperlink emission behind a “safe absolute URI” check (scheme allowlist).
  • Add regression tests for clicking relative links in both normal Markdown text and table cells, and adjust styling expectations.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Tests/UnitTestsParallelizable/Views/Markdown/MarkdownViewTests.cs Adds click regression tests for relative links (plain + table) and updates expected underline styling for relative links.
Terminal.Gui/Views/Markdown/MarkdownView.Drawing.cs Restricts OSC8 emission (Driver.CurrentUrl) to safe absolute URI targets only.
Terminal.Gui/Views/Markdown/MarkdownTable.cs Applies the same safe-absolute check for table rendering behavior tied to absolute URLs.
Terminal.Gui/Views/Markdown/Markdown.cs Adds a relative-link example to demo Markdown content.
Terminal.Gui/Drawing/Markdown/MarkdownAttributeHelper.cs Centralizes link-target detection (anchors/safe absolute/relative) and adds helper for safe absolute URI parsing.

Comment thread Tests/UnitTestsParallelizable/Views/Markdown/MarkdownViewTests.cs
Comment thread Tests/UnitTestsParallelizable/Views/Markdown/MarkdownViewTests.cs
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.

Markdown view treats relative links inconsistently with clickable links

3 participants