neo avatar
Neo Zero

markdown

Pool

Modern, tree-shakeable markdown parser with TypeScript support

$ lpm install @lpm.dev/neo.markdown
76 exportsTypeScript

dist

Functions

parse
function parse(markdown: string, options?: ParserOptions): string

Parse markdown to HTML

ParameterTypeDescription
markdown
string- Markdown source string
optionsoptional
ParserOptions- Parser options

dist/blocks

Variables

codeBlockRule

Fenced code block rule (` ``` ` or `~~~`).

definitionBlockRule

Link reference definition (`[label]: destination`).

indentedCodeBlockRule

Indented code block rule (four spaces or one tab).

headingBlockRule

ATX heading rule (`# Heading`).

setextHeadingBlockRule

Setext heading rule.

hrBlockRule

Horizontal rule (`---`, `***`, or `___`).

tableBlockRule

GFM table rule.

blockquoteBlockRule

Blockquote container rule.

listBlockRule

Ordered and unordered list container rule.

htmlBlockRule

Raw HTML block rule, active only when allowHtml is true.

paragraphBlockRule

Paragraph fallback rule.

allBlockRulesBlockRule[]

Complete default rule set in precedence order.

dist/blocks

Variables

codeBlockRule

Fenced code block rule (` ``` ` or `~~~`).

definitionBlockRule

Link reference definition (`[label]: destination`).

indentedCodeBlockRule

Indented code block rule (four spaces or one tab).

headingBlockRule

ATX heading rule (`# Heading`).

setextHeadingBlockRule

Setext heading rule.

hrBlockRule

Horizontal rule (`---`, `***`, or `___`).

tableBlockRule

GFM table rule.

blockquoteBlockRule

Blockquote container rule.

listBlockRule

Ordered and unordered list container rule.

htmlBlockRule

Raw HTML block rule, active only when allowHtml is true.

paragraphBlockRule

Paragraph fallback rule.

allBlockRulesBlockRule[]

Complete default rule set in precedence order.

dist/core

Functions

createParser
function createParser(options: ParserOptions & {
    blocks: BlockRule[];
}): Parser

Create a new parser instance

ParameterTypeDescription
options
ParserOptions & { blocks: BlockRule[]; }- Parser options

Classes

MarkdownParserimplements Parser

Markdown parser implementation

constructor(options?: ParserOptions, blockRules?: BlockRule[])
MethodReturn TypeDescription
parse(markdown)stringParse markdown to HTML
render(tokens)stringRender tokens through the same transforms and security pipeline as parse().
tokenize(markdown)BlockToken[]Tokenize markdown to block tokens
PluginBuilderImplimplements PluginBuilder

Internal plugin builder that collects plugin registrations

constructor(renderer: HtmlRenderer, options: ParserOptions)
MethodReturn TypeDescription
addBlockRule(rule)void
addInlineRule(rule)void
setRenderer(method, fn)void
addTokenTransform(fn)void
addHtmlTransform(fn)void
renderInline(tokens)string
renderBlock(tokens)string
PropertyTypeDescription
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

createParser
function createParser(options: ParserOptions & {
    blocks: BlockRule[];
}): Parser

Create a new parser instance

ParameterTypeDescription
options
ParserOptions & { blocks: BlockRule[]; }- Parser options

Classes

MarkdownParserimplements Parser

Markdown parser implementation

constructor(options?: ParserOptions, blockRules?: BlockRule[])
MethodReturn TypeDescription
parse(markdown)stringParse markdown to HTML
render(tokens)stringRender tokens through the same transforms and security pipeline as parse().
tokenize(markdown)BlockToken[]Tokenize markdown to block tokens
PluginBuilderImplimplements PluginBuilder

Internal plugin builder that collects plugin registrations

constructor(renderer: HtmlRenderer, options: ParserOptions)
MethodReturn TypeDescription
addBlockRule(rule)void
addInlineRule(rule)void
setRenderer(method, fn)void
addTokenTransform(fn)void
addHtmlTransform(fn)void
renderInline(tokens)string
renderBlock(tokens)string
PropertyTypeDescription
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

createParser
function createParser(options?: ParserOptions): Parser

Create a parser with all built-ins, or a caller-supplied selective rule set.

ParameterTypeDescription
optionsoptional
ParserOptions

dist/create-parser-YW3_EnJB

Functions

createParser
function createParser(options?: ParserOptions): Parser

Create a parser with all built-ins, or a caller-supplied selective rule set.

ParameterTypeDescription
optionsoptional
ParserOptions

dist/escape-C5Zvar9h

Functions

escape
function escape(html: string): string

Escape HTML entities to prevent XSS

ParameterTypeDescription
html
string- HTML string to escape

Variables

DEFAULT_ALLOWED_TAGSSet<string>

Default allowed tags (GitHub README-compatible).

DEFAULT_ALLOWED_ATTRIBUTESRecord<string, Set<string>>

Default allowed attributes per tag.

dist/escape-C5Zvar9h

Functions

escape
function escape(html: string): string

Escape HTML entities to prevent XSS

ParameterTypeDescription
html
string- HTML string to escape

Variables

DEFAULT_ALLOWED_TAGSSet<string>

Default allowed tags (GitHub README-compatible).

DEFAULT_ALLOWED_ATTRIBUTESRecord<string, Set<string>>

Default allowed attributes per tag.

dist/index-BeG9W3ai

Classes

InlineTokenizer

Inline tokenizer class

constructor(customRules?: InlineRule[], options?: InlineTokenizerOptions)
MethodReturn TypeDescription
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

InlineTokenizer

Inline tokenizer class

constructor(customRules?: InlineRule[], options?: InlineTokenizerOptions)
MethodReturn TypeDescription
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

parse
function parse(markdown: string, options?: ParserOptions): string

Parse markdown to HTML

ParameterTypeDescription
markdown
string- Markdown source string
optionsoptional
ParserOptions- Parser options

dist/plugins/copy-code

Functions

getCopyCodeStyles
function getCopyCodeStyles(options?: Pick<CopyCodeOptions, 'buttonClass' | 'wrapperClass'>): string

Return the default stylesheet so applications can serve it as a CSP-safe asset.

ParameterTypeDescription
optionsoptional
Pick<CopyCodeOptions, 'buttonClass' | 'wrapperClass'>
initializeCopyCode
function initializeCopyCode(options?: CopyCodeInitializerOptions): () => void

Install one delegated click handler for copy-code buttons.

ParameterTypeDescription
optionsoptional
CopyCodeInitializerOptions
copyCodePlugin
function copyCodePlugin(options?: CopyCodeOptions): MarkdownPlugin
ParameterTypeDescription
optionsoptional
CopyCodeOptions

dist/plugins/copy-code

Functions

getCopyCodeStyles
function getCopyCodeStyles(options?: Pick<CopyCodeOptions, 'buttonClass' | 'wrapperClass'>): string

Return the default stylesheet so applications can serve it as a CSP-safe asset.

ParameterTypeDescription
optionsoptional
Pick<CopyCodeOptions, 'buttonClass' | 'wrapperClass'>
initializeCopyCode
function initializeCopyCode(options?: CopyCodeInitializerOptions): () => void

Install one delegated click handler for copy-code buttons.

ParameterTypeDescription
optionsoptional
CopyCodeInitializerOptions
copyCodePlugin
function copyCodePlugin(options?: CopyCodeOptions): MarkdownPlugin
ParameterTypeDescription
optionsoptional
CopyCodeOptions

dist/plugins/embeds

Functions

initializeEmbeds
function initializeEmbeds(options?: EmbedInitializerOptions): () => void

Activate consent buttons, Gist scripts, and Twitter widgets.

ParameterTypeDescription
optionsoptional
EmbedInitializerOptions
embedPlugin
function embedPlugin(options?: EmbedOptions): MarkdownPlugin

Create the embed plugin

ParameterTypeDescription
optionsoptional
EmbedOptions- Embed options

dist/plugins/embeds

Functions

initializeEmbeds
function initializeEmbeds(options?: EmbedInitializerOptions): () => void

Activate consent buttons, Gist scripts, and Twitter widgets.

ParameterTypeDescription
optionsoptional
EmbedInitializerOptions
embedPlugin
function embedPlugin(options?: EmbedOptions): MarkdownPlugin

Create the embed plugin

ParameterTypeDescription
optionsoptional
EmbedOptions- Embed options

dist/plugins/embeds/react

Functions

pollTweetWidgets
function pollTweetWidgets(tryLoad: () => boolean, options?: TweetWidgetPollOptions): () => void

Poll a widget loader with a hard attempt limit and return a cancellation function.

ParameterTypeDescription
tryLoad
() => boolean
optionsoptional
TweetWidgetPollOptions

Variables

YouTubeFC<YouTubeProps>
VimeoFC<VimeoProps>
TWEET_WIDGET_RETRY_INTERVAL_MSunknown
TWEET_WIDGET_MAX_RETRIESunknown
TweetFC<TweetProps>
CodeSandboxFC<CodeSandboxProps>
CodePenFC<CodePenProps>
LoomFC<LoomProps>

dist/plugins/embeds/react

Functions

pollTweetWidgets
function pollTweetWidgets(tryLoad: () => boolean, options?: TweetWidgetPollOptions): () => void

Poll a widget loader with a hard attempt limit and return a cancellation function.

ParameterTypeDescription
tryLoad
() => boolean
optionsoptional
TweetWidgetPollOptions

Variables

YouTubeFC<YouTubeProps>
VimeoFC<VimeoProps>
TWEET_WIDGET_RETRY_INTERVAL_MSunknown
TWEET_WIDGET_MAX_RETRIESunknown
TweetFC<TweetProps>
CodeSandboxFC<CodeSandboxProps>
CodePenFC<CodePenProps>
LoomFC<LoomProps>

dist/plugins/highlight

Functions

parseHighlightLines
function parseHighlightLines(meta?: string, maxLines?: number): number[] | undefined

Parse highlight line ranges from meta string Supports formats: {1,3-5}, {1}, {1,2,3}

ParameterTypeDescription
metaoptional
string- Code block meta string
maxLinesoptional
number- Highest line number to return (hard-capped at 10,000)
highlightPlugin
function highlightPlugin(options: HighlightOptions): MarkdownPlugin

Create the highlight plugin

ParameterTypeDescription
options
HighlightOptions- Highlight options (grammars, tokenize, renderToHTML, theme, lineNumbers)

Variables

MAX_HIGHLIGHT_LINESunknown

Hard limit for expanded highlight metadata.

dist/plugins/highlight

Functions

parseHighlightLines
function parseHighlightLines(meta?: string, maxLines?: number): number[] | undefined

Parse highlight line ranges from meta string Supports formats: {1,3-5}, {1}, {1,2,3}

ParameterTypeDescription
metaoptional
string- Code block meta string
maxLinesoptional
number- Highest line number to return (hard-capped at 10,000)
highlightPlugin
function highlightPlugin(options: HighlightOptions): MarkdownPlugin

Create the highlight plugin

ParameterTypeDescription
options
HighlightOptions- Highlight options (grammars, tokenize, renderToHTML, theme, lineNumbers)

Variables

MAX_HIGHLIGHT_LINESunknown

Hard limit for expanded highlight metadata.

Unlimited AccessInstall as many Pool packages as you need.
Fund Real WorkEvery install you run sends revenue directly to the developer who built it.

Taxes calculated at checkout based on your location.

Weekly Installs
99
Version
2.0.0
Published
LicenseMIT
Size3.20 MiB
Files97
Node version>= 18
TypeScriptYes