protected internal DomDocumentImpl(Node adaptee) : base(adaptee) { _tt = new TagCollection(); }
public virtual bool IsWord2000(Node root, TagCollection tt) { Node html = root.FindHtml(tt); return (html != null && html.GetAttrByName("xmlns:o") != null); }
public Clean(TagCollection tt) { _tt = tt; }
/// <summary> /// Indicates whether or not whitespace should be preserved for this element. /// If an <code>xml:space</code> attribute is found, then if the attribute value is /// <code>preserve</code>, returns <code>true</code>. For any other value, returns /// <code>false</code>. If an <code>xml:space</code> attribute was <em>not</em> /// found, then the following element names result in a return value of /// <code>true: /// pre, script, style,</code> /// and <code>xsl:text</code>. Finally, if a /// <code>TagTable</code> was passed in and the element appears as the "pre" element /// in the <code>TagTable</code>, then <code>true</code> will be returned. /// Otherwise, <code>false</code> is returned. /// </summary> /// <param name="element"> /// The <code>Node</code> to test to see if whitespace should be /// preserved. /// </param> /// <param name="tt"> /// The <code>TagTable</code> to test for the <code>getNodePre()</code> /// function. This may be <code>null</code>, in which case this test /// is bypassed. /// </param> /// <returns> /// <code>true</code> or <code>false</code>, as explained above. /// </returns> public static bool XmlPreserveWhiteSpace(Node element, TagCollection tt) { AttVal attribute; /* search attributes for xml:space */ for (attribute = element.Attributes; attribute != null; attribute = attribute.Next) { if (attribute.Attribute.Equals("xml:space")) { if (attribute.Val.Equals("preserve")) { return true; } return false; } } /* kludge for html docs without explicit xml:space attribute */ if (String.CompareOrdinal(element.Element, "pre") == 0 || String.CompareOrdinal(element.Element, "script") == 0 || String.CompareOrdinal(element.Element, "style") == 0) { return true; } if ((tt != null) && (tt.FindParser(element) == ParsePre)) { return true; } /* kludge for XSL docs */ if (String.CompareOrdinal(element.Element, "xsl:text") == 0) { return true; } return false; }
public HtmlTidy() { _options = new TidyOptions(); AttributeTable at = AttributeTable.DefaultAttributeTable; if (at == null) return; var tt = new TagCollection {Options = _options}; _options.TagTable = tt; }
public Node(short type, byte[] textarray, int start, int end, string element, TagCollection tt) { Parent = null; Prev = null; Next = null; Last = null; Start = start; End = end; Textarray = textarray; this.type = type; Closed = false; Isimplicit = false; Linebreak = false; Was = null; Tag = null; this.element = element; Attributes = null; Content = null; if (type == START_TAG || type == START_END_TAG || type == END_TAG) { tt.FindTag(this); } }
/* find html element */ public virtual Node FindHtml(TagCollection tt) { Node node; //TODO:odd! for (node = Content; node != null && node.Tag != tt.TagHtml; node = node.Next) { } return node; }
public virtual Node FindHead(TagCollection tt) { Node node = FindHtml(tt); if (node != null) { //TODO:odd! for (node = node.Content; node != null && node.Tag != tt.TagHead; node = node.Next) { } } return node; }
public virtual Node FindBody(TagCollection tt) { Node node = Content; while (node != null && node.Tag != tt.TagHtml) { node = node.Next; } if (node == null) { return null; } node = node.Content; while (node != null && node.Tag != tt.TagBody) { node = node.Next; } return node; }
/* unexpected content in table row is moved to just before the table in accordance with Netscape and IE. This code assumes that node hasn't been inserted into the row. */ public static void MoveBeforeTable(Node row, Node node, TagCollection tt) { Node table; /* first find the table element */ for (table = row.Parent; table != null; table = table.Parent) { if (table.Tag == tt.TagTable) { if (table.Parent.Content == table) { table.Parent.Content = node; } node.Prev = table.Prev; node.Next = table; table.Prev = node; node.Parent = table.Parent; if (node.Prev != null) { node.Prev.Next = node; } break; } } }