Skip to main content

MarkdownParser class

📖 Description

The MarkdownParser class is a fast parser for markdown text.

🗃️ Fields


🏷️ features

Retrieves the features that the current MarkdownParser instance supports.

Type

MarkdownFeatures


🏷️ hasMentions

Retrieves if the parsed markdown AST contains mentions.

Type

boolean


🏷️ hasReferences

Retrieves if the parsed markdown AST contains references.

Type

boolean


🏷️ text

Retrieves the plain text without markdown formatting (all markdown markup is removed).

Type

string

▶️ Methods


🔧 map

Maps the markdown AST to a structure.

Signature

map<R>(
fn: (
type: "paragraph" | "break" | "bold" | "italic" | "bold+italic" | "underline" | "strikethrough" | "code" | "hyperlink" | "image" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "codeblock" | "codeline" | "quote" | "mention" | "reference" | undefined,
content: string,
value: string | T | undefined,
parent: R | undefined,
kind: "root" | "text" | "node"
) => R
): R

Parameters

NameTypeOptionalDescription
fnSee signatureNoSpecifies the map function that is invoked for each item in the AST.

Return value

Returns the ancestor R of the map structure.


🔧 reduce

Reduces the markdown AST.

Signature

reduce<R>(
fn: (
type: "paragraph" | "break" | "bold" | "italic" | "bold+italic" | "underline" | "strikethrough" | "code" | "hyperlink" | "image" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "codeblock" | "codeline" | "quote" | "mention" | "reference" | undefined,
content: string | R[],
value: string | T | undefined
) => R
): R

Parameters

NameTypeOptionalDescription
fnSee signatureNoSpecifies the reduce function that is invoked for each item in the AST.

Return value

Returns the reduced value R.