Skip to content

Add support for HTML <a> anchor tags with links#53

Merged
LittleLittleCloud merged 5 commits intomainfrom
copilot/support-a-tag
Oct 23, 2025
Merged

Add support for HTML <a> anchor tags with links#53
LittleLittleCloud merged 5 commits intomainfrom
copilot/support-a-tag

Conversation

Copy link
Contributor

Copilot AI commented Oct 23, 2025

This PR adds support for HTML <a> anchor tags in RazorConsole, enabling developers to create clickable hyperlinks in their console applications using familiar HTML syntax.

What's New

RazorConsole now supports the <a> tag with href attributes, which are automatically converted to Spectre.Console's link markup format. Links will be clickable in modern terminals that support hyperlinks (Windows Terminal, iTerm2, GNOME Terminal, etc.).

Basic Usage

<p>Visit <a href="https://example.com">example.com</a> for more info.</p>

Advanced Features

Multiple links in text:

<p>Check out <a href="https://github.com">GitHub</a> or <a href="https://microsoft.com">Microsoft</a></p>

Links with nested formatting:

<a href="https://example.com"><strong>Bold Link</strong></a>
<a href="https://example.com"><em>Italic Link</em></a>

Automatic fallback:

<a>Text without href renders as plain text</a>

Implementation Details

Changes Made

  1. Extended HtmlInlineTextElementTranslator: Added support for <a> tags alongside existing inline elements like <strong>, <em>, and <code>. URLs are automatically escaped for safety, and nested formatting is fully supported.

  2. Fixed ParagraphElementTranslator: Updated to handle mixed content (text + inline elements) instead of text-only content. This allows <p> tags to contain anchor links and other inline formatting elements, making the paragraph translator more robust and consistent with HTML semantics.

Testing

  • Added 5 comprehensive unit tests covering various anchor tag scenarios
  • All existing 64 tests continue to pass
  • Tested on both .NET 8.0 and .NET 9.0
  • Verified with live demo application

Breaking Changes

None. This is a purely additive feature that extends existing functionality without modifying any public APIs or breaking existing behavior.

Original prompt

This section details on the original issue you should resolve

<issue_title>Support tag</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #52


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Oct 23, 2025
Copilot AI and others added 2 commits October 23, 2025 14:13
Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for a tag element Add support for HTML <a> anchor tags with links Oct 23, 2025
@LittleLittleCloud LittleLittleCloud marked this pull request as ready for review October 23, 2025 14:42
@LittleLittleCloud LittleLittleCloud merged commit a8f600c into main Oct 23, 2025
4 checks passed
@LittleLittleCloud LittleLittleCloud deleted the copilot/support-a-tag branch October 23, 2025 15:41
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.

Support <a> tag

3 participants