GenericAttributesExtension Class

Extension that allows to attach HTML attributes to the previous Inline or current Block. This extension should be enabled last after enabling other extensions.

public class GenericAttributesExtension : IMarkdownExtension
Implements

Constructors

NameDescription
GenericAttributesExtension()

GenericAttributesExtension()

GenericAttributesExtension.cs
public GenericAttributesExtension()

No documentation is available.

Properties

NameDescription
AttributeFilterGets or sets the predicate that decides whether an attribute parsed from the Markdown (other than the id and the classes) is written to the HTML. The default value is GenericAttributesExtension.IsSafeAttributeName.

Gets or sets the predicate that decides whether an attribute parsed from the Markdown (other than the id and the classes) is written to the HTML. The default value is GenericAttributesExtension.IsSafeAttributeName.

public Func<string, bool> AttributeFilter { get; set; }

Property value

Func<string, bool>

Methods

NameDescription
IsSafeAttributeName(string)Returns true for the attributes that only describe the content, such as title, lang, alt, colspan, target, role and aria-*: the general attributes that Meziantou.Framework.HtmlSanitizer allows, other than class. Other attributes are rejected, including event handlers, attributes that hold a URL, style, name, and the data-* and directive attributes that client-side frameworks execute. Use GenericAttributesExtension.AttributeFilter to allow more attributes when the Markdown is trusted.
Setup(MarkdownPipeline, IMarkdownRenderer)Configures this extension for the specified pipeline stage.
Setup(MarkdownPipelineBuilder)Configures this extension for the specified pipeline stage.

IsSafeAttributeName(string)

GenericAttributesExtension.cs

Returns true for the attributes that only describe the content, such as title, lang, alt, colspan, target, role and aria-*: the general attributes that Meziantou.Framework.HtmlSanitizer allows, other than class. Other attributes are rejected, including event handlers, attributes that hold a URL, style, name, and the data-* and directive attributes that client-side frameworks execute. Use GenericAttributesExtension.AttributeFilter to allow more attributes when the Markdown is trusted.

public static bool IsSafeAttributeName(string name)

Parameters

name string
The name of the attribute.

Returns

bool true if the attribute can be written to the HTML output.

Setup overloads

Setup(MarkdownPipeline, IMarkdownRenderer)

GenericAttributesExtension.cs

Configures this extension for the specified pipeline stage.

public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer)
Parameters
pipeline MarkdownPipeline
renderer IMarkdownRenderer

Setup(MarkdownPipelineBuilder)

GenericAttributesExtension.cs

Configures this extension for the specified pipeline stage.

public void Setup(MarkdownPipelineBuilder pipeline)
Parameters
pipeline MarkdownPipelineBuilder