Skip to content

Commit

Permalink
Fix: EmphasisInline not detected
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdotnet committed Jul 4, 2024
1 parent dd32f71 commit 4a9de25
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/LinkDotNet.Blog.Web/Features/MarkdownConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private static string InlineToString(ContainerInline inline)
{
CodeInline cd => cd.Content,
LinkInline link => link.FirstChild?.ToString(),
EmphasisInline em => em.FirstChild?.ToString(),
_ => current.ToString()
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,17 @@ public void ShouldSetAnchorLinkCorrectWhenAlreadyAnchorInUrl()
links[1].GetAttribute("href").Should().Be("https://localhost#header-2");
}

[Fact]
public void ShouldCreateCorrectTocWithCodeInHeadings()
[Theory]
[InlineData("# This is `Header` 1", "This is Header 1")]
[InlineData("# [This is a link](https://link.com)", "This is a link")]
[InlineData("# **What** *if*", "What if")]
public void ShouldCreateCorrectToc(string markdown, string expectedToc)
{
const string content = "# This is `Header` 1";

var cut = Render<TableOfContents>(p => p
.Add(x => x.Content, content)
.Add(x => x.CurrentUri, "https://localhost"));

var link = cut.Find("nav a");
link.TextContent.Should().Be("This is Header 1");
}

[Fact]
public void ShouldCreateCorrectTocWithLinkInHeadings()
{
const string content = "# [This is a link](https://link.com)";

var cut = Render<TableOfContents>(p => p
.Add(x => x.Content, content)
.Add(x => x.Content, markdown)
.Add(x => x.CurrentUri, "https://localhost"));

var link = cut.Find("nav a");
link.TextContent.Should().Be("This is a link");
link.TextContent.Should().Be(expectedToc);
}
}

0 comments on commit 4a9de25

Please sign in to comment.