Beispiel #1
0
 /// <summary>Normalise the document.</summary>
 /// <remarks>
 /// Normalise the document. This happens after the parse phase so generally does not need to be called.
 /// Moves any text content that is not in the body element into the body.
 /// </remarks>
 /// <returns>this document after normalisation</returns>
 public virtual iText.StyledXmlParser.Jsoup.Nodes.Document Normalise()
 {
     iText.StyledXmlParser.Jsoup.Nodes.Element htmlEl = FindFirstElementByTagName("html", this);
     if (htmlEl == null)
     {
         htmlEl = AppendElement("html");
     }
     if (Head() == null)
     {
         htmlEl.PrependElement("head");
     }
     if (Body() == null)
     {
         htmlEl.AppendElement("body");
     }
     // pull text nodes out of root, html, and head els, and push into body. non-text nodes are already taken care
     // of. do in inverse order to maintain text order.
     NormaliseTextNodes(Head());
     NormaliseTextNodes(htmlEl);
     NormaliseTextNodes(this);
     NormaliseStructure("head", htmlEl);
     NormaliseStructure("body", htmlEl);
     EnsureMetaCharsetElement();
     return(this);
 }