diff --git a/samples/MudBlazor.Markdown.Core/MudBlazor.Markdown.Core.csproj b/samples/MudBlazor.Markdown.Core/MudBlazor.Markdown.Core.csproj index d4870ca..c9b7a1b 100644 --- a/samples/MudBlazor.Markdown.Core/MudBlazor.Markdown.Core.csproj +++ b/samples/MudBlazor.Markdown.Core/MudBlazor.Markdown.Core.csproj @@ -9,7 +9,7 @@ - + diff --git a/samples/Server/MudBlazor.Markdown.Server.csproj b/samples/Server/MudBlazor.Markdown.Server.csproj index 8ae90de..310cf8e 100644 --- a/samples/Server/MudBlazor.Markdown.Server.csproj +++ b/samples/Server/MudBlazor.Markdown.Server.csproj @@ -7,7 +7,7 @@ - + diff --git a/samples/WebAssembly/MudBlazor.Markdown.Wasm.csproj b/samples/WebAssembly/MudBlazor.Markdown.Wasm.csproj index 2042dbe..6fc70a5 100644 --- a/samples/WebAssembly/MudBlazor.Markdown.Wasm.csproj +++ b/samples/WebAssembly/MudBlazor.Markdown.Wasm.csproj @@ -7,9 +7,9 @@ - - - + + + diff --git a/src/MudBlazor.Markdown/Helpers/MudMarkdownStyling.cs b/src/MudBlazor.Markdown/Helpers/MudMarkdownStyling.cs index 533292d..17b8ddb 100644 --- a/src/MudBlazor.Markdown/Helpers/MudMarkdownStyling.cs +++ b/src/MudBlazor.Markdown/Helpers/MudMarkdownStyling.cs @@ -2,23 +2,36 @@ public sealed class MudMarkdownStyling { - public TableStyling Table { get; } = new(); - - public sealed class TableStyling - { - /// - /// If true, striped table rows will be used. - /// - public bool IsStriped { get; set; } = true; + /// + /// Styling properties for the table. + /// + public TableStyling Table { get; } = new(); - /// - /// If true, table's cells will have left/right borders. - /// - public bool IsBordered { get; set; } = true; - - /// - /// Child content of component. - /// - public int Elevation { set; get; } = 1; - } + /// + /// Styling properties for the link. + /// + public LinkStyling Link { get; } = new(); + + public sealed class TableStyling + { + /// + /// If true, striped table rows will be used. + /// + public bool IsStriped { get; set; } = true; + + /// + /// If true, table's cells will have left/right borders. + /// + public bool IsBordered { get; set; } = true; + + /// + /// Child content of component. + /// + public int Elevation { set; get; } = 1; + } + + public sealed class LinkStyling + { + public Underline Underline { get; set; } = Underline.Hover; + } } diff --git a/src/MudBlazor.Markdown/MudMarkdown.razor.cs b/src/MudBlazor.Markdown/MudMarkdown.razor.cs index 47ab467..643694a 100644 --- a/src/MudBlazor.Markdown/MudMarkdown.razor.cs +++ b/src/MudBlazor.Markdown/MudMarkdown.razor.cs @@ -276,6 +276,7 @@ protected virtual void RenderInlines(ContainerInline inlines, RenderTreeBuilder { builder.OpenComponent(ElementIndex++); builder.AddAttribute(ElementIndex++, nameof(MudLink.Href), url); + builder.AddAttribute(ElementIndex++, nameof(MudLink.Underline), Styling.Link.Underline); builder.AddAttribute(ElementIndex++, nameof(MudLink.ChildContent), (RenderFragment)(linkBuilder => RenderInlines(x, linkBuilder))); if (url.IsExternalUri(NavigationManager?.BaseUri)) diff --git a/tests/MudBlazor.Markdown.Tests/MarkdownComponentTests/MarkdownComponentStylingShould.cs b/tests/MudBlazor.Markdown.Tests/MarkdownComponentTests/MarkdownComponentStylingShould.cs index c7cd8a1..121c331 100644 --- a/tests/MudBlazor.Markdown.Tests/MarkdownComponentTests/MarkdownComponentStylingShould.cs +++ b/tests/MudBlazor.Markdown.Tests/MarkdownComponentTests/MarkdownComponentStylingShould.cs @@ -44,8 +44,8 @@ public void RenderTableNotStriped() { Table = { - IsStriped = false - } + IsStriped = false, + }, }; using var fixture = CreateFixture(value, styling: styling); @@ -94,8 +94,8 @@ public void RenderTableNotBordered() { Table = { - IsBordered = false - } + IsBordered = false, + }, }; using var fixture = CreateFixture(value, styling: styling); @@ -144,11 +144,59 @@ public void RenderTableNoElevation() { Table = { - Elevation = 0 - } + Elevation = 0, + }, }; using var fixture = CreateFixture(value, styling: styling); fixture.MarkupMatches(expected); } + + [Fact] + public void RenderLinkUnderlineAlways() + { + const string value = "[my link](https://www.mynihongo.org/)"; + + const string expected = +@""; + + var styling = new MudMarkdownStyling + { + Link = + { + Underline = Underline.Always, + }, + }; + + using var fixture = CreateFixture(value, styling: styling); + fixture.MarkupMatches(expected); + } + + [Fact] + public void RenderLinkUnderlineNone() + { + const string value = "[my link](https://www.mynihongo.org/)"; + + const string expected = +@""; + + var styling = new MudMarkdownStyling + { + Link = + { + Underline = Underline.None, + }, + }; + + using var fixture = CreateFixture(value, styling: styling); + fixture.MarkupMatches(expected); + } } diff --git a/tests/MudBlazor.Markdown.Tests/MudBlazor.Markdown.Tests.csproj b/tests/MudBlazor.Markdown.Tests/MudBlazor.Markdown.Tests.csproj index a990fd5..7c524b6 100644 --- a/tests/MudBlazor.Markdown.Tests/MudBlazor.Markdown.Tests.csproj +++ b/tests/MudBlazor.Markdown.Tests/MudBlazor.Markdown.Tests.csproj @@ -8,7 +8,7 @@ - +