MarkdownInlineExtension Class

An inline syntax that starts at one of MarkdownInlineExtension.TriggerCharacters, such as @mention or {{variable}}. The parser calls MarkdownInlineExtension.TryParse at each trigger character, before the built-in syntaxes, and the construct becomes a MarkdownExtensionInlineSyntax.

public abstract class MarkdownInlineExtension : MarkdownSyntaxExtension

Remarks

The extensions of a character are tried in the order of MarkdownParseOptions.SyntaxExtensions, then the built-in syntaxes. A construct is atomic, as a code span: the delimiters of emphasis and the brackets of links do not match across its edges, and the content added with MarkdownInlineParseContext.AddInlines is parsed on its own. The parser does not call extensions in code spans, in autolinks, in raw HTML, or after a backslash.

One instance parses every document, possibly on several threads at once: keep no state between calls.

Inheritance
MarkdownSyntaxExtension MarkdownInlineExtension

Constructors

NameDescription
MarkdownInlineExtension(string, string)Initializes a new instance of the MarkdownInlineExtension class.

MarkdownInlineExtension(string, string)

MarkdownInlineExtension.cs

Initializes a new instance of the MarkdownInlineExtension class.

protected MarkdownInlineExtension(string name, string triggerCharacters)

Parameters

name string
The name of the extension, which the nodes of its constructs have.
triggerCharacters string
The characters where a construct can start: not whitespace.

Exceptions

ArgumentException
name or triggerCharacters is empty, or triggerCharacters has whitespace.
ArgumentNullException
name or triggerCharacters is null.

Properties

NameDescription
TriggerCharactersGets the characters where a construct can start.

Gets the characters where a construct can start.

public string TriggerCharacters { get; }

Property value

string

Methods

NameDescription
TryParse(MarkdownInlineParseContext)Reads a construct at a trigger character, the first character of MarkdownInlineParseContext.Text.

TryParse(MarkdownInlineParseContext)

Reads a construct at a trigger character, the first character of MarkdownInlineParseContext.Text.

public abstract bool TryParse(ref MarkdownInlineParseContext context)

Parameters

context MarkdownInlineParseContext
The text from the trigger character, where the construct reports its parts and its length.

Returns

bool true when the text is a construct, after calling MarkdownInlineParseContext.Complete; false to let the next extension, or the built-in syntaxes, read the text.