HtmlRenderer Class

Default HTML renderer for a Markdown MarkdownDocument object.

public class HtmlRenderer : TextRendererBase<HtmlRenderer>
Inheritance
TextRendererBase<HtmlRenderer> HtmlRenderer

Constructors

NameDescription
HtmlRenderer(TextWriter)Initializes a new instance of the HtmlRenderer class.

HtmlRenderer(TextWriter)

HtmlRenderer.cs

Initializes a new instance of the HtmlRenderer class.

public HtmlRenderer(TextWriter writer)

Parameters

writer TextWriter
The writer.

Properties

NameDescription
BaseUrlGets a value to use as the base url for all relative links
EnableHtmlEscapeGets or sets the enable html escape.
EnableHtmlForBlockGets or sets a value indicating whether to output HTML tags when rendering. See remarks.
EnableHtmlForInlineGets or sets a value indicating whether to output HTML tags when rendering. See remarks.
ImplicitParagraphGets or sets a value indicating whether to use implicit paragraph (optional <p>)
LinkRewriterAllows links to be rewritten
UseNonAsciiNoEscapeGets or sets the use non ascii no escape.

Gets a value to use as the base url for all relative links

public Uri? BaseUrl { get; set; }

Property value

Uri?

EnableHtmlEscape

HtmlRenderer.cs

Gets or sets the enable html escape.

public bool EnableHtmlEscape { get; set; }

Property value

bool

EnableHtmlForBlock

HtmlRenderer.cs

Gets or sets a value indicating whether to output HTML tags when rendering. See remarks.

public bool EnableHtmlForBlock { get; set; }

Property value

bool

Remarks

This is used by some renderers to disable HTML tags when rendering some block elements (for image links).

EnableHtmlForInline

HtmlRenderer.cs

Gets or sets a value indicating whether to output HTML tags when rendering. See remarks.

public bool EnableHtmlForInline { get; set; }

Property value

bool

Remarks

This is used by some renderers to disable HTML tags when rendering some inline elements (for image links).

ImplicitParagraph

HtmlRenderer.cs

Gets or sets a value indicating whether to use implicit paragraph (optional <p>)

public bool ImplicitParagraph { get; set; }

Property value

bool

LinkRewriter

HtmlRenderer.cs

Allows links to be rewritten

public Func<string, string>? LinkRewriter { get; set; }

Property value

Func<string, string>?

UseNonAsciiNoEscape

HtmlRenderer.cs

Gets or sets the use non ascii no escape.

public bool UseNonAsciiNoEscape { get; set; }

Property value

bool

Methods

NameDescription
WriteAttributes(HtmlAttributes?, Func<string, string>?)Writes the specified HtmlAttributes.
WriteAttributes(MarkdownObject)Writes the attached HtmlAttributes on the specified MarkdownObject.
WriteEscape(StringSlice, bool)Writes the content escaped for HTML.
WriteEscape(StringSlice, bool)Writes the content escaped for HTML.
WriteEscape(ReadOnlySpan<char>, bool)Writes the content escaped for HTML.
WriteEscape(string?)Writes the content escaped for HTML.
WriteEscape(string, int, int, bool)Writes the content escaped for HTML.
WriteEscapeUrl(string?)Writes the URL escaped for HTML.
WriteLeafRawLines(LeafBlock, bool, bool, bool)Writes the lines of a LeafBlock

WriteAttributes overloads

WriteAttributes(HtmlAttributes?, Func<string, string>?)

HtmlRenderer.cs

Writes the specified HtmlAttributes.

public HtmlRenderer WriteAttributes(HtmlAttributes? attributes, Func<string, string>? classFilter = null)
Parameters
attributes HtmlAttributes?
The attributes to render.
classFilter Func<string, string>?
A class filter used to transform a class into another class at writing time
Returns

HtmlRenderer This instance

WriteAttributes(MarkdownObject)

HtmlRenderer.cs

Writes the attached HtmlAttributes on the specified MarkdownObject.

public HtmlRenderer WriteAttributes(MarkdownObject markdownObject)
Parameters
markdownObject MarkdownObject
The object.
Returns

HtmlRenderer

WriteEscape overloads

WriteEscape(StringSlice, bool)

HtmlRenderer.cs

Writes the content escaped for HTML.

public HtmlRenderer WriteEscape(StringSlice slice, bool softEscape = false)
Parameters
slice StringSlice
The slice.
softEscape bool
Only escape < and &
Returns

HtmlRenderer This instance

WriteEscape(StringSlice, bool)

HtmlRenderer.cs

Writes the content escaped for HTML.

public HtmlRenderer WriteEscape(ref StringSlice slice, bool softEscape = false)
Parameters
slice StringSlice
The slice.
softEscape bool
Only escape < and &
Returns

HtmlRenderer This instance

WriteEscape(ReadOnlySpan<char>, bool)

HtmlRenderer.cs

Writes the content escaped for HTML.

public void WriteEscape(ReadOnlySpan<char> content, bool softEscape = false)
Parameters
content ReadOnlySpan<char>
The content.
softEscape bool
Only escape < and &

WriteEscape(string?)

HtmlRenderer.cs

Writes the content escaped for HTML.

public HtmlRenderer WriteEscape(string? content)
Parameters
content string?
The content.
Returns

HtmlRenderer This instance

WriteEscape(string, int, int, bool)

HtmlRenderer.cs

Writes the content escaped for HTML.

public HtmlRenderer WriteEscape(string content, int offset, int length, bool softEscape = false)
Parameters
content string
The content.
offset int
The offset.
length int
The length.
softEscape bool
Only escape < and &
Returns

HtmlRenderer This instance

WriteEscapeUrl(string?)

HtmlRenderer.cs

Writes the URL escaped for HTML.

public HtmlRenderer WriteEscapeUrl(string? content)

Parameters

content string?
The content.

Returns

HtmlRenderer This instance

WriteLeafRawLines(LeafBlock, bool, bool, bool)

HtmlRenderer.cs

Writes the lines of a LeafBlock

public HtmlRenderer WriteLeafRawLines(LeafBlock leafBlock, bool writeEndOfLines, bool escape, bool softEscape = false)

Parameters

leafBlock LeafBlock
The leaf block.
writeEndOfLines bool
if set to true write end of lines.
escape bool
if set to true escape the content for HTML
softEscape bool
Only escape < and &

Returns

HtmlRenderer This instance