T

MarkdownRule

A simple-markdown rule: match finds it at the start of the source, parse builds its node, react renders it.

type MarkdownRule<TNode extends MarkdownNode = MarkdownNode> = { … }

Members

order?number

Discord 349 ships highlight, guild and channel without one; the parser never calls those.

match(source: string, state: MarkdownState, previous: string): RegExpExecArray | null

Matches the rule at the start of source; previous is the text already consumed. null means no match.

parse(capture: RegExpExecArray, parse: MarkdownNestedParse, state: MarkdownState): TNode

Builds the node from match's capture; call parse to parse nested Markdown.

react?(node: TNode, output: MarkdownOutput, state: MarkdownState): ReactNode

Renders the node; call output to render its children.