正确的html缺少<p>标签</p>

时间:2015-04-17 09:03:02

标签: c# html xml

目前我正在研究纠正HTML的解决方案。在我们的解决方案中,我们有一个富文本编辑器,我们希望在用户忘记<p>元素时更正HTML,这种情况会发生很多。

var input = new StringBuilder();
input.AppendLine("<h2>title1</h2>");
input.AppendLine("text");
input.AppendLine("<h2>title2</h2>");
input.AppendLine("<p>paragraph</p>");

var expected = new StringBuilder();
expected.AppendLine("<h2>title1</h2>");
expected.AppendLine("<p>text</p>");
expected.AppendLine("<h2>title2</h2>");
expected.AppendLine("<p>paragraph</p>");

Assert.AreEqual(expected.ToString(), input.DoSomething());

HTML敏捷包中有什么东西吗?那还有另一种解决方案吗?

1 个答案:

答案 0 :(得分:0)

不确定这是否有帮助,但有一个类似的主题:

How to fix ill-formed HTML with HTML Agility Pack?

此外,不是您的问题,但我们使用Markdown编辑器而不是HTML编辑器获得了良好的效果。

相关问题