public override void OuterHtmlHead(StringBuilder accum, int depth, OutputSettings output) { string html = Entities.Escape(GetWholeText(), output); if (output.PrettyPrint() && ParentNode is Element && !((Element)ParentNode).PreserveWhitespace) { html = NormaliseWhitespace(html); } if (output.PrettyPrint() && SiblingIndex == 0 && ParentNode is Element && ((Element)ParentNode).Tag.FormatAsBlock && !IsBlank) { Indent(accum, depth, output); } accum.Append(html); }
public object Clone() { OutputSettings clone = new OutputSettings(); clone.SetEncoding(_encoding.WebName); // new charset and charset encoder clone.SetEscapeMode(_escapeMode); clone.PrettyPrint(_prettyPrint); clone.IndentAmount(_indentAmount); return(clone); }
public override void OuterHtmlTail(StringBuilder accum, int depth, OutputSettings output) { if (!(ChildNodes.Count == 0 && Tag.IsSelfClosing)) { if (output.PrettyPrint() && ChildNodes.Count != 0 && Tag.FormatAsBlock) { Indent(accum, depth, output); } accum.Append("</").Append(TagName()).Append(">"); } }
public override void OuterHtmlHead(StringBuilder accum, int depth, OutputSettings output) { if (output.PrettyPrint()) { Indent(accum, depth, output); } accum .Append("<!--") .Append(GetData()) .Append("-->"); }
public override void OuterHtmlHead(StringBuilder accum, int depth, OutputSettings output) { if (accum.Length > 0 && output.PrettyPrint() && (Tag.FormatAsBlock || (Parent != null && Parent.Tag.FormatAsBlock))) { Indent(accum, depth, output); } accum.Append("<") .Append(TagName()); Attributes.Html(accum, output); if (ChildNodes.Count <= 0 && _tag.IsSelfClosing) { accum.Append(" />"); } else { accum.Append(">"); } }
public object Clone() { OutputSettings clone = new OutputSettings(); clone.SetEncoding(_encoding.WebName); // new charset and charset encoder clone.EscapeMode = _escapeMode; clone.PrettyPrint(_prettyPrint); clone.IndentAmount(_indentAmount); return clone; }
public void supplyOutputSettings() { // test that one can override the default document output settings OutputSettings os = new OutputSettings(); os.PrettyPrint(false); os.EscapeMode = Entities.EscapeMode.Extended; string html = "<div><p>ℬ</p></div>"; string customOut = NSoupClient.Clean(html, "http://foo.com/", Whitelist.Relaxed, os); string defaultOut = NSoupClient.Clean(html, "http://foo.com/", Whitelist.Relaxed); Assert.AreNotSame(defaultOut, customOut); Assert.AreEqual("<div><p>ℬ</p></div>", customOut); Assert.AreEqual("<div>\n" + " <p>ג„¬</p>\n" + "</div>", defaultOut); os.Encoding = Encoding.ASCII; os.EscapeMode = Entities.EscapeMode.Base; String customOut2 = NSoupClient.Clean(html, "http://foo.com/", Whitelist.Relaxed, os); Assert.AreEqual("<div><p>ℬ</p></div>", customOut2); }