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
🏷️ 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
Name | Type | Optional | Description |
---|---|---|---|
fn | See signature | No | Specifies 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
Name | Type | Optional | Description |
---|---|---|---|
fn | See signature | No | Specifies the reduce function that is invoked for each item in the AST. |
Return value
Returns the reduced value R
.