Skip to content

Fix link parsing to terminate properly#2091

Merged
patriksvensson merged 2 commits intospectreconsole:mainfrom
zhuman:zhuman/fix_links
Apr 16, 2026
Merged

Fix link parsing to terminate properly#2091
patriksvensson merged 2 commits intospectreconsole:mainfrom
zhuman:zhuman/fix_links

Conversation

@zhuman
Copy link
Copy Markdown
Contributor

@zhuman zhuman commented Apr 16, 2026

Fixes #2090

  • I have read the Contribution Guidelines
  • I have checked that there isn't already another pull request that solves the above issue
  • All newly added code is adequately covered by tests
  • All existing tests are still running without errors

I used GitHub Copilot to generate the new tests.

Changes

This change is pretty straightforward - it promotes links to be treated similarly to styles in the markup parser, where they are parsed out of new tags and pushed into a stack. Closing the tag caused them to get popped from the stack. The AnsiMarkupSegments comparison that is used to merge together text of the same style now compares the active link.

Three new tests were added to SelectionPrompt confirming that links embedded in SelectionPrompts don't exhibit the incorrect behavior (this is where I originally noticed the issues). Two new tests were added to AnsiConsoleTests.Markup to validate that nesting and link closure works.


Please upvote 👍 this pull request if you are interested in it.

@zhuman zhuman changed the title Zhuman/fix links Fix links in markup Apr 16, 2026
@zhuman zhuman changed the title Fix links in markup Fix link parsing to terminate properly Apr 16, 2026
@patriksvensson patriksvensson merged commit 270afc3 into spectreconsole:main Apr 16, 2026
3 checks passed
@patriksvensson
Copy link
Copy Markdown
Contributor

Merged! Thank you for your contribution. Much appreciated! 👍

This was referenced Apr 16, 2026
This was referenced Apr 21, 2026
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.

Links do not terminate properly and multiple links per markup block don't work

2 participants