diff --git a/src/Markdig.Tests/TestHtmlCodeBlocks.cs b/src/Markdig.Tests/TestHtmlCodeBlocks.cs new file mode 100644 index 00000000..5935d6ef --- /dev/null +++ b/src/Markdig.Tests/TestHtmlCodeBlocks.cs @@ -0,0 +1,35 @@ +using Markdig.Syntax; + +namespace Markdig.Tests; + +public class TestHtmlCodeBlocks +{ + // Start condition: line begins with the string < or , or the string />. + public static string[] KnownSimpleHtmlTags => + [ + "address", "article", "aside", "base", "basefont", "blockquote", "body", "caption", "center", "col", "colgroup", "dd", "details", + "dialog", "dir", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", "form", "frame", "frameset", + "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hr", "html", "iframe", "legend", "li", "link", + "main", "menu", "menuitem", "nav", "noframes", "ol", "optgroup", "option", "p", "param", + "search", "section", "summary", "table", "tbody", "td", "tfoot", "th", "thead", "title", "tr", "track", "ul", + ]; + + [Theory] + [TestCaseSource(nameof(KnownSimpleHtmlTags))] + public void TestKnownTags(string tag) + { + MarkdownDocument document = Markdown.Parse( + $""" + Hello + <{tag} /> + World + """.ReplaceLineEndings("\n")); + + HtmlBlock[] htmlBlocks = document.Descendants().ToArray(); + + Assert.AreEqual(1, htmlBlocks.Length); + Assert.AreEqual(7, htmlBlocks[0].Span.Start); + Assert.AreEqual(10 + tag.Length, htmlBlocks[0].Span.Length); + } +} \ No newline at end of file diff --git a/src/Markdig/Parsers/HtmlBlockParser.cs b/src/Markdig/Parsers/HtmlBlockParser.cs index bcc6ca73..5c85e228 100644 --- a/src/Markdig/Parsers/HtmlBlockParser.cs +++ b/src/Markdig/Parsers/HtmlBlockParser.cs @@ -295,7 +295,7 @@ public class HtmlBlockParser : BlockParser return BlockState.Continue; } - private static readonly CompactPrefixTree HtmlTags = new(66, 94, 83) + private static readonly CompactPrefixTree HtmlTags = new(67, 96, 86) { { "address", 0 }, { "article", 1 }, @@ -362,6 +362,7 @@ public class HtmlBlockParser : BlockParser { "title", 62 }, { "tr", 63 }, { "track", 64 }, - { "ul", 65 } + { "ul", 65 }, + { "search", 66 }, }; } \ No newline at end of file