Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Spectre.Console/Style.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ public string ToMarkup()
builder.Add("on " + Background.ToMarkup());
}

if (Link != null)
{
builder.Add($"link={Link}");
}

return string.Join(" ", builder);
}

Expand Down
26 changes: 26 additions & 0 deletions src/Tests/Spectre.Console.Tests/Unit/StyleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,5 +405,31 @@ public void Should_Return_Expected_Markup_For_Style_With_Only_Background_Color()
// Then
result.ShouldBe("default on green");
}

[Fact]
public void Should_Return_Expected_Markup_For_Style_With_Only_Link()
{
// Given
var style = new Style(link:"https://spectreconsole.net/");

// When
var result = style.ToMarkup();

// Then
result.ShouldBe("link=https://spectreconsole.net/");
}

[Fact]
public void Should_Return_Expected_Markup_For_Style_With_Background_And_Link()
{
// Given
var style = new Style(background: Color.Blue, link: "https://spectreconsole.net/");

// When
var result = style.ToMarkup();

// Then
result.ShouldBe("default on blue link=https://spectreconsole.net/");
}
}
}