public override string ToString() { string retVal = ""; foreach (HtmlTagNode subnode in this) { retVal += HtmlTagTree.printNode(0, subnode); } return(retVal); }
private void Parse(string html) { Inlines.Clear(); if (html == null) { return; } HtmlTagTree tree = new HtmlTagTree(); HtmlParser parser = new HtmlParser(tree); //output parser.Parse(new StringReader(html)); //input HtmlUpdater updater = new HtmlUpdater(this); //output updater.Update(tree); }
public void Update(HtmlTagTree tagTree) { List <HtmlTag> tagList = tagTree.ToHtmlTagList(); foreach (HtmlTag tag in tagList) { if (tag.ID != -1) { switch (Defines.BuiltinTags[tag.ID].flags) { case HTMLFlag.TextFormat: UpdateStyle(tag); break; case HTMLFlag.Element: textBlock.Inlines.Add(UpdateElement(tag)); break; } } } }
static string printNode(Int32 level, HtmlTagNode node) { string spacing = " "; string retVal = ""; for (int i = 0; i < level; i++) { spacing += " "; } retVal += spacing + node.ToString() + '\r' + '\n'; foreach (HtmlTagNode subnode in node) { retVal += HtmlTagTree.printNode(level + 1, subnode); } return(retVal); }
private void Parse(string html) { if (!String.IsNullOrEmpty(Highlight)) { int idx = html.IndexOf(Highlight, StringComparison.InvariantCultureIgnoreCase); while (idx != -1) { html = String.Format("{0}[b]{1}[/b]{2}", html.Substring(0, idx), html.Substring(idx, Highlight.Length), html.Substring(idx + Highlight.Length)); idx = html.IndexOf(Highlight, idx + 7 + Highlight.Length, StringComparison.InvariantCultureIgnoreCase); } } Inlines.Clear(); HtmlTagTree tree = new HtmlTagTree(); HtmlParser parser = new HtmlParser(tree); //output parser.Parse(new StringReader(html)); //input HtmlUpdater updater = new HtmlUpdater(this); //output updater.Update(tree); }
/// <summary> /// Constructor /// </summary> public HtmlParser(HtmlTagTree aTree) { tree = aTree; }