public void TestTagProcessor2Tags() { string html = "1<@code >2</@code>3<@code>4</@code>5"; TagProcessor tagProcessor = new TagProcessor("@code", html); string result = tagProcessor.Replace((openTag, content, closeTag) => { return "(" + content + ")"; }); Assert.AreEqual("1(2)3(4)5", result); }
public void TestTagProcessorParse() { // 1 // 0123456789012345678 string html = "1<@code >2</@code>3"; TagProcessor tagProcessor = new TagProcessor("@code", html); List<TagProcessor.Item> items = tagProcessor.Items; // Assert.AreEqual(5, items.Count); // Assert.IsTrue(items[0].Start == 0); Assert.IsTrue(items[0].Length == 1); Assert.IsTrue(items[0].Kind == TagProcessor.ItemKind.Text); // Assert.IsTrue(items[1].Start == 1); Assert.IsTrue(items[1].Length == 8); Assert.IsTrue(items[1].Kind == TagProcessor.ItemKind.OpenTag); // Assert.IsTrue(items[2].Start == 9); Assert.IsTrue(items[2].Length == 1); Assert.IsTrue(items[2].Kind == TagProcessor.ItemKind.Content); // Assert.IsTrue(items[3].Start == 10); Assert.IsTrue(items[3].Length == 8); Assert.IsTrue(items[3].Kind == TagProcessor.ItemKind.CloseTag); // Assert.IsTrue(items[4].Start == 18); Assert.IsTrue(items[4].Length == 1); Assert.IsTrue(items[4].Kind == TagProcessor.ItemKind.Text); }
private string doProcess(string html) { TagProcessor tagProcessor = new TagProcessor("@codeblock", html); string result = tagProcessor.Replace(this.doReplace); // if (Globals.OutSettings.DevOutMode) { result = this.calcExampleProblemsListHtml() + result; } // return result; }
// <@overloads title="get_item_sig()"> // <@item title="static get_item_sig(i, arr_depth-opt)"> // ... // </@item> // </@overloads> private string doProcess(string html) { TagProcessor tagProcessor = new TagProcessor("@overloads", html); return tagProcessor.Replace(this.doReplace); }
public void TestTagProcessorReplace3() { string html = "1<@code />2<@code>3</@code>"; TagProcessor tagProcessor = new TagProcessor("@code", html); string result = tagProcessor.Replace((openTag, content, closeTag) => { return "()"; }); Assert.AreEqual("1()2()", result); }