/// <summary> Finish off a tag. /// Perhap add a virtual end tag. /// Set the end tag parent as this tag. /// Perform the semantic acton. /// </summary> /// <param name="tag">The tag to finish off. /// </param> /// <param name="lexer">A lexer positioned at the end of the tag. /// </param> protected internal virtual void FinishTag(ITag tag, Lexer lexer) { if (null == tag.GetEndTag()) { tag.SetEndTag(CreateVirtualEndTag(tag, lexer, lexer.Page, lexer.Cursor.Position)); } tag.GetEndTag().Parent = tag; tag.DoSemanticAction(); }
private static string HtmlNode2PlainText(INode htmlNode) { if (htmlNode == null) { return(""); } string text = ""; if (htmlNode.Children == null || htmlNode.Children.Count == 0) { text = htmlNode.ToPlainTextString(); } else { INode child = htmlNode.FirstChild; while (child != null) { if (child is ITag) { ITag tag = child as ITag; if (tag.TagName == "SCRIPT") { if (tag.GetEndTag() != null) { child = tag.GetEndTag().NextSibling; } else { child = child.NextSibling; } continue; } } text += HtmlNode2PlainText(child); child = child.NextSibling; } } return(text); }