MarkdownHtmlRendererOptions Class
Configures how MarkdownHtmlRenderer writes HTML.
public sealed class MarkdownHtmlRendererOptions : IEquatable<MarkdownHtmlRendererOptions>- Implements
Constructors
| Name | Description |
|---|---|
| MarkdownHtmlRendererOptions() |
MarkdownHtmlRendererOptions()
MarkdownHtmlRendererOptions.cspublic MarkdownHtmlRendererOptions()No documentation is available.
Properties
| Name | Description |
|---|---|
| AllowedUrlSchemes | Gets the schemes that the URLs of the links and of the images can have, such as http, https and mailto, or null to write every URL, as CommonMark does. A URL with another scheme, such as javascript: or data:, is written empty. A relative URL has no scheme and is always written. |
| AttributeFilter | Gets which attributes of MarkdownExtensions.GenericAttributes the renderer writes, by name. The id and the classes are always written. |
| BaseUrl | Gets the URL that the relative URLs of the links and of the images are relative to, or null to keep them relative. |
| Default | Gets the options used when none are given. |
| EscapeNonAsciiUrlCharacters | Gets a value indicating whether the characters of the URLs that are not ASCII are percent-encoded, as CommonMark does. Markdig keeps them for nonascii-noescape. |
| IdPrefix | Gets the prefix of the ids that the document sets, such as user-content- as GitHub writes them, or null for none: the ids of MarkdownExtensions.AutoIdentifiers and of MarkdownExtensions.GenericAttributes, the ids of the footnotes and of their references, and the links that the renderer writes to them. Several documents rendered on one page, such as comments, then have different ids. |
| LinkRel | Gets the rel attribute of the links, such as nofollow noopener, or null for none. The autolinks of email addresses between < and > have none. |
| LinkRewriter | Gets a function that changes the URLs of the links and of the images, after MarkdownHtmlRendererOptions.BaseUrl, or null. |
| MediaLinks | Gets how the images of audio, video, and of the sites that host them are rendered with MarkdownExtensions.MediaLinks. |
| NodeRenderers | Gets the renderers that write some nodes instead of the built-in rendering, such as the code blocks of a language. Each block and each inline is offered to them in order, and the first one that writes it wins. |
| PragmaLines | Gets a value indicating whether the element of the first block of each line has the id pragma-line-N, where N is the zero-based number of the line, as Markdig does with pragma lines: an editor can scroll its preview to a line. A block whose id is set gets an anchor with the id instead. |
| SmartyPants | Gets the HTML that the renderer writes for each character of MarkdownExtensions.SmartyPants, written as it is: by default, the entities ‘, ’, “, ”, «, », …, – and —. |
AllowedUrlSchemes
MarkdownHtmlRendererOptions.csGets the schemes that the URLs of the links and of the images can have, such as http, https and mailto, or null to write every URL, as CommonMark does. A URL with another scheme, such as javascript: or data:, is written empty. A relative URL has no scheme and is always written.
public ImmutableArray<string>? AllowedUrlSchemes { get; init; }Property value
Remarks
The scheme is compared ignoring case, and read from the URL that is written, after MarkdownHtmlRendererOptions.BaseUrl and MarkdownHtmlRendererOptions.LinkRewriter, as a browser reads it: the spaces and the control characters at the start of the URL, and its tabs and line endings, are ignored.
The filter applies to the URLs that the renderer writes, including the ones of MarkdownHtmlWriter.WriteUrl. It does not apply to raw HTML, nor to the generic attributes that MarkdownHtmlRendererOptions.AttributeFilter allows: it complements an HTML sanitizer, it does not replace one.
AttributeFilter
MarkdownHtmlRendererOptions.csGets which attributes of MarkdownExtensions.GenericAttributes the renderer writes, by name. The id and the classes are always written.
Property value
Remarks
By default, only the attributes that describe the content are written, such as title, lang or aria-*: event handlers, URL attributes, style or data-* can run script or change the page when the Markdown is not trusted.
Gets the options used when none are given.
public static MarkdownHtmlRendererOptions Default { get; }Property value
EscapeNonAsciiUrlCharacters
MarkdownHtmlRendererOptions.csIdPrefix
MarkdownHtmlRendererOptions.csGets the prefix of the ids that the document sets, such as user-content- as GitHub writes them, or null for none: the ids of MarkdownExtensions.AutoIdentifiers and of MarkdownExtensions.GenericAttributes, the ids of the footnotes and of their references, and the links that the renderer writes to them. Several documents rendered on one page, such as comments, then have different ids.
public string? IdPrefix { get; init; }Property value
Remarks
The links that the text writes, such as [a](#b), and the ids of MarkdownHtmlRendererOptions.PragmaLines are kept as they are.
Example
var options = new MarkdownParseOptions { Extensions = MarkdownExtensions.AutoIdentifiers | MarkdownExtensions.Footnotes };
var tree = MarkdownSyntaxTree.ParseText("# Notes\n\nSee[^1].\n\n[^1]: A note.\n", options);
// Several documents rendered on one page, such as comments, have different ids
var html = MarkdownHtmlRenderer.ToHtml(tree, new MarkdownHtmlRendererOptions { IdPrefix = "comment-1-" });
Assert.Equal("<h1 id=\"comment-1-notes\">Notes</h1>\n<p>See<a id=\"comment-1-fnref:1\" href=\"#comment-1-fn:1\" class=\"footnote-ref\"><sup>1</sup></a>.</p>\n<div class=\"footnotes\">\n<hr />\n<ol>\n<li id=\"comment-1-fn:1\">\n<p>A note.<a href=\"#comment-1-fnref:1\" class=\"footnote-back-ref\">↩</a></p>\n</li>\n</ol>\n</div>\n", html);LinkRewriter
MarkdownHtmlRendererOptions.csGets a function that changes the URLs of the links and of the images, after MarkdownHtmlRendererOptions.BaseUrl, or null.
Property value
MediaLinks
MarkdownHtmlRendererOptions.csGets how the images of audio, video, and of the sites that host them are rendered with MarkdownExtensions.MediaLinks.
public MarkdownMediaLinkOptions MediaLinks { get; init; }Property value
NodeRenderers
MarkdownHtmlRendererOptions.csGets the renderers that write some nodes instead of the built-in rendering, such as the code blocks of a language. Each block and each inline is offered to them in order, and the first one that writes it wins.
public ImmutableArray<MarkdownHtmlNodeRenderer> NodeRenderers { get; init; }Property value
PragmaLines
MarkdownHtmlRendererOptions.csGets a value indicating whether the element of the first block of each line has the id pragma-line-N, where N is the zero-based number of the line, as Markdig does with pragma lines: an editor can scroll its preview to a line. A block whose id is set gets an anchor with the id instead.
public bool PragmaLines { get; init; }Property value
SmartyPants
MarkdownHtmlRendererOptions.csGets the HTML that the renderer writes for each character of MarkdownExtensions.SmartyPants, written as it is: by default, the entities ‘, ’, “, ”, «, », …, – and —.
public IReadOnlyDictionary<MarkdownSmartyPant, string> SmartyPants { get; init; }Property value
IReadOnlyDictionary<MarkdownSmartyPant, string>
Remarks
A character that the mapping does not have is written as the default entity.
Methods
| Name | Description |
|---|---|
| Equals(MarkdownHtmlRendererOptions?) | |
| Equals(object?) | |
| GetHashCode() | |
| IsSafeAttributeName(string) | Gets whether an attribute only describes the content: whatever its value, it cannot run script or load a resource. |
| ToString() |
Equals overloads
Equals(MarkdownHtmlRendererOptions?)
public bool Equals(MarkdownHtmlRendererOptions? other)No documentation is available.
Equals(object?)
GetHashCode()
IsSafeAttributeName(string)
MarkdownHtmlRendererOptions.csGets whether an attribute only describes the content: whatever its value, it cannot run script or load a resource.
ToString()
Operators
| Name | Description |
|---|---|
| operator ==(MarkdownHtmlRendererOptions?, MarkdownHtmlRendererOptions?) | |
| operator !=(MarkdownHtmlRendererOptions?, MarkdownHtmlRendererOptions?) |
operator ==(MarkdownHtmlRendererOptions?, MarkdownHtmlRendererOptions?)
public static bool operator ==(MarkdownHtmlRendererOptions? left, MarkdownHtmlRendererOptions? right)No documentation is available.
operator !=(MarkdownHtmlRendererOptions?, MarkdownHtmlRendererOptions?)
public static bool operator !=(MarkdownHtmlRendererOptions? left, MarkdownHtmlRendererOptions? right)No documentation is available.