HtmlPrettyFormatter Class

Writes an indented HTML markup, to read or compare documents: each node is written on its own line, indented by its depth, and the whitespace of the text is collapsed and trimmed.

public sealed class HtmlPrettyFormatter : HtmlFormatter

Remarks

The whitespace is not significant in the output, so the document it represents may be rendered differently: use HtmlFormatter.Default or HtmlMinifyFormatter to write a document that is served. The content of the elements whose whitespace is significant (pre, textarea, listing, script, style...) is written as is, except the CSS of the style elements when HtmlFormatter.StyleElementFormatter is set: it is written on the lines that follow the start tag, indented by the depth of its content. An element whose only content is a text is written on a single line.

Inheritance
HtmlFormatter HtmlPrettyFormatter

Constructors

NameDescription
HtmlPrettyFormatter()

HtmlPrettyFormatter()

HtmlPrettyFormatter.cs
public HtmlPrettyFormatter()

No documentation is available.

Properties

NameDescription
IndentationThe string written for each level of indentation. The default is two spaces.
MaxIndentationDepthThe maximum number of indentation levels: the content of the deeper elements is indented as the content at this depth. The default is 64, which bounds the size of the output of deeply nested input (the indentation of each line would grow with the depth).
NewLineThe line separator. The default is "\n".

The string written for each level of indentation. The default is two spaces.

public string Indentation { get; init; }

Property value

string

MaxIndentationDepth

HtmlPrettyFormatter.cs

The maximum number of indentation levels: the content of the deeper elements is indented as the content at this depth. The default is 64, which bounds the size of the output of deeply nested input (the indentation of each line would grow with the depth).

public int MaxIndentationDepth { get; init; }

Property value

int

The line separator. The default is "\n".

public string NewLine { get; init; }

Property value

string