/// <summary> /// Returns an HTML-code representation of the node. /// </summary> /// <param name="formatter">The formatter to use.</param> /// <returns>A string containing the HTML code.</returns> public override String ToHtml(IMarkupFormatter formatter) { var open = formatter.OpenTag(this, false); var children = _content.ChildNodes.ToHtml(formatter); var close = formatter.CloseTag(this, false); return String.Concat(open, children, close); }
/// <summary> /// Returns an HTML-code representation of the node. /// </summary> /// <param name="formatter">The formatter to use.</param> /// <returns>A string containing the HTML code.</returns> public override String ToHtml(IMarkupFormatter formatter) { var selfClosing = Flags.HasFlag(NodeFlags.SelfClosing); var open = formatter.OpenTag(this, selfClosing); var children = String.Empty; if (!selfClosing) { var sb = Pool.NewStringBuilder(); if (Flags.HasFlag(NodeFlags.LineTolerance) && FirstChild is IText) { var text = (IText)FirstChild; if (text.Data.Length > 0 && text.Data[0] == Symbols.LineFeed) { sb.Append(Symbols.LineFeed); } } foreach (var child in ChildNodes) { sb.Append(child.ToHtml(formatter)); } children = sb.ToPool(); } var close = formatter.CloseTag(this, selfClosing); return(String.Concat(open, children, close)); }
public override void ToHtml(TextWriter writer, IMarkupFormatter formatter) { var selfClosing = Flags.HasFlag(NodeFlags.SelfClosing); writer.Write(formatter.OpenTag(this, selfClosing)); if (!selfClosing) { if (Flags.HasFlag(NodeFlags.LineTolerance) && FirstChild is IText) { var text = (IText)FirstChild; if (text.Data.Has(Symbols.LineFeed)) { writer.Write(Symbols.LineFeed); } } foreach (var child in ChildNodes) { child.ToHtml(writer, formatter); } } writer.Write(formatter.CloseTag(this, selfClosing)); }
/// <summary> /// Returns an HTML-code representation of the node. /// </summary> /// <param name="formatter">The formatter to use.</param> /// <returns>A string containing the HTML code.</returns> public override String ToHtml(IMarkupFormatter formatter) { var open = formatter.OpenTag(this, false); var children = _content.ChildNodes.ToHtml(formatter); var close = formatter.CloseTag(this, false); return(String.Concat(open, children, close)); }
/// <summary> /// Returns an HTML-code representation of the node. /// </summary> /// <param name="formatter">The formatter to use.</param> /// <returns>A string containing the HTML code.</returns> public override String ToHtml(IMarkupFormatter formatter) { var tagName = NodeName; var attributeStrings = new String[Attributes.Count]; for (int i = 0; i < attributeStrings.Length; i++) { var attribute = Attributes[i]; attributeStrings[i] = formatter.Attribute(attribute); } var open = formatter.OpenTag(tagName, attributeStrings, false); var children = _content.ChildNodes.ToHtml(formatter); var close = formatter.CloseTag(tagName, false); return(String.Concat(open, children, close)); }
/// <summary> /// Returns an HTML-code representation of the node. /// </summary> /// <param name="formatter">The formatter to use.</param> /// <returns>A string containing the HTML code.</returns> public override String ToHtml(IMarkupFormatter formatter) { var selfClosing = Flags.HasFlag(NodeFlags.SelfClosing); var tagName = (Flags & (NodeFlags.HtmlMember | NodeFlags.SvgMember | NodeFlags.MathMember)) != NodeFlags.None ? LocalName : NodeName; var attributeStrings = new String[_attributes.Count]; for (var i = 0; i < _attributes.Count; i++) { var attribute = _attributes[i]; attributeStrings[i] = formatter.Attribute(attribute); } var open = formatter.OpenTag(tagName, attributeStrings, selfClosing); var children = String.Empty; if (!selfClosing) { var sb = Pool.NewStringBuilder(); if (Flags.HasFlag(NodeFlags.LineTolerance) && FirstChild is IText) { var text = (IText)FirstChild; if (text.Data.Length > 0 && text.Data[0] == Symbols.LineFeed) { sb.Append(Symbols.LineFeed); } } foreach (var child in ChildNodes) { sb.Append(child.ToHtml(formatter)); } children = sb.ToPool(); } var close = formatter.CloseTag(tagName, selfClosing); return(String.Concat(open, children, close)); }
/// <summary> /// Returns an HTML-code representation of the node. /// </summary> /// <param name="formatter">The formatter to use.</param> /// <returns>A string containing the HTML code.</returns> public override String ToHtml(IMarkupFormatter formatter) { var selfClosing = Flags.HasFlag(NodeFlags.SelfClosing); var open = formatter.OpenTag(this, selfClosing); var children = String.Empty; if (!selfClosing) { var sb = Pool.NewStringBuilder(); if (Flags.HasFlag(NodeFlags.LineTolerance) && FirstChild is IText) { var text = (IText)FirstChild; if (text.Data.Length > 0 && text.Data[0] == Symbols.LineFeed) sb.Append(Symbols.LineFeed); } foreach (var child in ChildNodes) sb.Append(child.ToHtml(formatter)); children = sb.ToPool(); } var close = formatter.CloseTag(this, selfClosing); return String.Concat(open, children, close); }
/// <inheritdoc /> public string CloseTag(IElement element, bool selfClosing) => _formatter.CloseTag(element, selfClosing);
public override void ToHtml(TextWriter writer, IMarkupFormatter formatter) { writer.Write(formatter.OpenTag(this, false)); _content.ChildNodes.ToHtml(writer, formatter); writer.Write(formatter.CloseTag(this, false)); }
public string CloseTag(IElement element, bool selfClosing) { return(defaultFormatter.CloseTag(element, selfClosing)); }