markdown
PoolModern, tree-shakeable markdown parser with TypeScript support
dist
Functions
function parse(markdown: string, options?: ParserOptions): string
Parse markdown to HTML
| Parameter | Type | Description |
|---|---|---|
markdown | string | - Markdown source string |
optionsoptional | ParserOptions | - Parser options |
dist/blocks
Variables
BlockRuleFenced code block rule (` ``` ` or `~~~`).
BlockRuleLink reference definition (`[label]: destination`).
BlockRuleIndented code block rule (four spaces or one tab).
BlockRuleATX heading rule (`# Heading`).
BlockRuleSetext heading rule.
BlockRuleHorizontal rule (`---`, `***`, or `___`).
BlockRuleGFM table rule.
BlockRuleBlockquote container rule.
BlockRuleOrdered and unordered list container rule.
BlockRuleRaw HTML block rule, active only when allowHtml is true.
BlockRuleParagraph fallback rule.
BlockRule[]Complete default rule set in precedence order.
dist/blocks
Variables
BlockRuleFenced code block rule (` ``` ` or `~~~`).
BlockRuleLink reference definition (`[label]: destination`).
BlockRuleIndented code block rule (four spaces or one tab).
BlockRuleATX heading rule (`# Heading`).
BlockRuleSetext heading rule.
BlockRuleHorizontal rule (`---`, `***`, or `___`).
BlockRuleGFM table rule.
BlockRuleBlockquote container rule.
BlockRuleOrdered and unordered list container rule.
BlockRuleRaw HTML block rule, active only when allowHtml is true.
BlockRuleParagraph fallback rule.
BlockRule[]Complete default rule set in precedence order.
dist/core
Functions
function createParser(options: ParserOptions & {
blocks: BlockRule[];
}): ParserCreate a new parser instance
| Parameter | Type | Description |
|---|---|---|
options | ParserOptions & {
blocks: BlockRule[];
} | - Parser options |
Classes
Markdown parser implementation
constructor(options?: ParserOptions, blockRules?: BlockRule[])
| Method | Return Type | Description |
|---|---|---|
parse(markdown) | string | Parse markdown to HTML |
render(tokens) | string | Render tokens through the same transforms and security pipeline as parse(). |
tokenize(markdown) | BlockToken[] | Tokenize markdown to block tokens |
Internal plugin builder that collects plugin registrations
constructor(renderer: HtmlRenderer, options: ParserOptions)
| Method | Return Type | Description |
|---|---|---|
addBlockRule(rule) | void | |
addInlineRule(rule) | void | |
setRenderer(method, fn) | void | |
addTokenTransform(fn) | void | |
addHtmlTransform(fn) | void | |
renderInline(tokens) | string | |
renderBlock(tokens) | string |
| Property | Type | Description |
|---|---|---|
options | Readonly<ParserOptions> | |
blockRules | BlockRule[] | Collected custom block rules |
inlineRules | InlineRule[] | Collected custom inline rules |
rendererOverrides | Map<keyof Renderer, ((token: HeadingToken) => string) | ((token: ParagraphToken) => string) | ((token: CodeToken) => string) | ((token: HrToken) => string) | ((token: BlockquoteToken) => string) | ((token: ListToken) => string) | ((token: ListItemToken) => string) | ((token: HtmlBlockToken | HtmlInlineToken) => string) | ((token: TableToken) => string) | ((cells: string[]) => string) | ((text: string, align: "left" | "center" | "right" | null, header: boolean) => string) | ((token: DirectiveToken) => string) | ((token: TextToken) => string) | ((token: StrongToken) => string) | ((token: EmToken) => string) | ((token: DelToken) => string) | ((token: CodeInlineToken) => string) | ((token: LinkToken) => string) | ((token: ImageToken) => string) | ((token: BrToken) => string)> | Collected renderer overrides (method name → function) |
tokenTransforms | Array<(tokens: BlockToken[]) => BlockToken[]> | Collected token transforms (run after tokenization) |
htmlTransforms | Array<(html: string) => string> | Collected HTML transforms (run after rendering) |
dist/core
Functions
function createParser(options: ParserOptions & {
blocks: BlockRule[];
}): ParserCreate a new parser instance
| Parameter | Type | Description |
|---|---|---|
options | ParserOptions & {
blocks: BlockRule[];
} | - Parser options |
Classes
Markdown parser implementation
constructor(options?: ParserOptions, blockRules?: BlockRule[])
| Method | Return Type | Description |
|---|---|---|
parse(markdown) | string | Parse markdown to HTML |
render(tokens) | string | Render tokens through the same transforms and security pipeline as parse(). |
tokenize(markdown) | BlockToken[] | Tokenize markdown to block tokens |
Internal plugin builder that collects plugin registrations
constructor(renderer: HtmlRenderer, options: ParserOptions)
| Method | Return Type | Description |
|---|---|---|
addBlockRule(rule) | void | |
addInlineRule(rule) | void | |
setRenderer(method, fn) | void | |
addTokenTransform(fn) | void | |
addHtmlTransform(fn) | void | |
renderInline(tokens) | string | |
renderBlock(tokens) | string |
| Property | Type | Description |
|---|---|---|
options | Readonly<ParserOptions> | |
blockRules | BlockRule[] | Collected custom block rules |
inlineRules | InlineRule[] | Collected custom inline rules |
rendererOverrides | Map<keyof Renderer, ((token: HeadingToken) => string) | ((token: ParagraphToken) => string) | ((token: CodeToken) => string) | ((token: HrToken) => string) | ((token: BlockquoteToken) => string) | ((token: ListToken) => string) | ((token: ListItemToken) => string) | ((token: HtmlBlockToken | HtmlInlineToken) => string) | ((token: TableToken) => string) | ((cells: string[]) => string) | ((text: string, align: "left" | "center" | "right" | null, header: boolean) => string) | ((token: DirectiveToken) => string) | ((token: TextToken) => string) | ((token: StrongToken) => string) | ((token: EmToken) => string) | ((token: DelToken) => string) | ((token: CodeInlineToken) => string) | ((token: LinkToken) => string) | ((token: ImageToken) => string) | ((token: BrToken) => string)> | Collected renderer overrides (method name → function) |
tokenTransforms | Array<(tokens: BlockToken[]) => BlockToken[]> | Collected token transforms (run after tokenization) |
htmlTransforms | Array<(html: string) => string> | Collected HTML transforms (run after rendering) |
dist/create-parser-5cb0v2Xn
Functions
function createParser(options?: ParserOptions): Parser
Create a parser with all built-ins, or a caller-supplied selective rule set.
| Parameter | Type | Description |
|---|---|---|
optionsoptional | ParserOptions |
dist/create-parser-YW3_EnJB
Functions
function createParser(options?: ParserOptions): Parser
Create a parser with all built-ins, or a caller-supplied selective rule set.
| Parameter | Type | Description |
|---|---|---|
optionsoptional | ParserOptions |
dist/escape-C5Zvar9h
Functions
function escape(html: string): string
Escape HTML entities to prevent XSS
| Parameter | Type | Description |
|---|---|---|
html | string | - HTML string to escape |
Variables
Set<string>Default allowed tags (GitHub README-compatible).
Record<string, Set<string>>Default allowed attributes per tag.
dist/escape-C5Zvar9h
Functions
function escape(html: string): string
Escape HTML entities to prevent XSS
| Parameter | Type | Description |
|---|---|---|
html | string | - HTML string to escape |
Variables
Set<string>Default allowed tags (GitHub README-compatible).
Record<string, Set<string>>Default allowed attributes per tag.
dist/index-BeG9W3ai
Classes
Inline tokenizer class
constructor(customRules?: InlineRule[], options?: InlineTokenizerOptions)
| Method | Return Type | Description |
|---|---|---|
tokenize(src, references) | InlineToken[] | Tokenize inline markdown string Phase 6: Optimized with fast-path checks to avoid unnecessary regex execution |
normalizeReferenceLabel(label) | string |
dist/index-C6tY9uuy
Classes
Inline tokenizer class
constructor(customRules?: InlineRule[], options?: InlineTokenizerOptions)
| Method | Return Type | Description |
|---|---|---|
tokenize(src, references) | InlineToken[] | Tokenize inline markdown string Phase 6: Optimized with fast-path checks to avoid unnecessary regex execution |
normalizeReferenceLabel(label) | string |
dist
Functions
function parse(markdown: string, options?: ParserOptions): string
Parse markdown to HTML
| Parameter | Type | Description |
|---|---|---|
markdown | string | - Markdown source string |
optionsoptional | ParserOptions | - Parser options |
dist/plugins/copy-code
Functions
function getCopyCodeStyles(options?: Pick<CopyCodeOptions, 'buttonClass' | 'wrapperClass'>): string
Return the default stylesheet so applications can serve it as a CSP-safe asset.
| Parameter | Type | Description |
|---|---|---|
optionsoptional | Pick<CopyCodeOptions, 'buttonClass' | 'wrapperClass'> |
function initializeCopyCode(options?: CopyCodeInitializerOptions): () => void
Install one delegated click handler for copy-code buttons.
| Parameter | Type | Description |
|---|---|---|
optionsoptional | CopyCodeInitializerOptions |
function copyCodePlugin(options?: CopyCodeOptions): MarkdownPlugin
| Parameter | Type | Description |
|---|---|---|
optionsoptional | CopyCodeOptions |
dist/plugins/copy-code
Functions
function getCopyCodeStyles(options?: Pick<CopyCodeOptions, 'buttonClass' | 'wrapperClass'>): string
Return the default stylesheet so applications can serve it as a CSP-safe asset.
| Parameter | Type | Description |
|---|---|---|
optionsoptional | Pick<CopyCodeOptions, 'buttonClass' | 'wrapperClass'> |
function initializeCopyCode(options?: CopyCodeInitializerOptions): () => void
Install one delegated click handler for copy-code buttons.
| Parameter | Type | Description |
|---|---|---|
optionsoptional | CopyCodeInitializerOptions |
function copyCodePlugin(options?: CopyCodeOptions): MarkdownPlugin
| Parameter | Type | Description |
|---|---|---|
optionsoptional | CopyCodeOptions |
dist/plugins/embeds
Functions
function initializeEmbeds(options?: EmbedInitializerOptions): () => void
Activate consent buttons, Gist scripts, and Twitter widgets.
| Parameter | Type | Description |
|---|---|---|
optionsoptional | EmbedInitializerOptions |
function embedPlugin(options?: EmbedOptions): MarkdownPlugin
Create the embed plugin
| Parameter | Type | Description |
|---|---|---|
optionsoptional | EmbedOptions | - Embed options |
dist/plugins/embeds
Functions
function initializeEmbeds(options?: EmbedInitializerOptions): () => void
Activate consent buttons, Gist scripts, and Twitter widgets.
| Parameter | Type | Description |
|---|---|---|
optionsoptional | EmbedInitializerOptions |
function embedPlugin(options?: EmbedOptions): MarkdownPlugin
Create the embed plugin
| Parameter | Type | Description |
|---|---|---|
optionsoptional | EmbedOptions | - Embed options |
dist/plugins/embeds/react
Functions
function pollTweetWidgets(tryLoad: () => boolean, options?: TweetWidgetPollOptions): () => void
Poll a widget loader with a hard attempt limit and return a cancellation function.
| Parameter | Type | Description |
|---|---|---|
tryLoad | () => boolean | |
optionsoptional | TweetWidgetPollOptions |
Variables
FC<YouTubeProps>FC<VimeoProps>unknownunknownFC<TweetProps>FC<CodeSandboxProps>FC<CodePenProps>FC<LoomProps>dist/plugins/embeds/react
Functions
function pollTweetWidgets(tryLoad: () => boolean, options?: TweetWidgetPollOptions): () => void
Poll a widget loader with a hard attempt limit and return a cancellation function.
| Parameter | Type | Description |
|---|---|---|
tryLoad | () => boolean | |
optionsoptional | TweetWidgetPollOptions |
Variables
FC<YouTubeProps>FC<VimeoProps>unknownunknownFC<TweetProps>FC<CodeSandboxProps>FC<CodePenProps>FC<LoomProps>dist/plugins/highlight
Functions
function parseHighlightLines(meta?: string, maxLines?: number): number[] | undefined
Parse highlight line ranges from meta string Supports formats: {1,3-5}, {1}, {1,2,3}
| Parameter | Type | Description |
|---|---|---|
metaoptional | string | - Code block meta string |
maxLinesoptional | number | - Highest line number to return (hard-capped at 10,000) |
function highlightPlugin(options: HighlightOptions): MarkdownPlugin
Create the highlight plugin
| Parameter | Type | Description |
|---|---|---|
options | HighlightOptions | - Highlight options (grammars, tokenize, renderToHTML, theme, lineNumbers) |
Variables
unknownHard limit for expanded highlight metadata.
dist/plugins/highlight
Functions
function parseHighlightLines(meta?: string, maxLines?: number): number[] | undefined
Parse highlight line ranges from meta string Supports formats: {1,3-5}, {1}, {1,2,3}
| Parameter | Type | Description |
|---|---|---|
metaoptional | string | - Code block meta string |
maxLinesoptional | number | - Highest line number to return (hard-capped at 10,000) |
function highlightPlugin(options: HighlightOptions): MarkdownPlugin
Create the highlight plugin
| Parameter | Type | Description |
|---|---|---|
options | HighlightOptions | - Highlight options (grammars, tokenize, renderToHTML, theme, lineNumbers) |
Variables
unknownHard limit for expanded highlight metadata.
Taxes calculated at checkout based on your location.