【发布时间】:2015-06-24 01:04:12
【问题描述】:
目前我正在研究纠正 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 敏捷包中有什么东西吗?有没有别的解决办法?
【问题讨论】:
-
即使你不使用 HTML AP,使用 stringbuilder 也是自找麻烦,.net 中有一个内置的 HTMLDocument 类会有所改进。