The `markdown-parser` library provides a robust and fully typed parser for Markdown content, adhering strictly to the CommonMark specification and including full support for GitHub Flavored Markdown (GFM) tables. Currently at version 0.1.1, its primary differentiation is its advanced streaming and incremental parsing capabilities, which are especially critical for applications consuming continuously arriving content, such as outputs from large language models or real-time communication systems. Unlike conventional Markdown parsers that necessitate complete input before generating an Abstract Syntax Tree (AST), `markdown-parser` can process text in chunks, emitting finalized block nodes as they become stable while internally managing the state of incomplete structures. This design allows for immediate display and dynamic manipulation of Markdown content without waiting for the entire stream to conclude. The library is engineered to produce a structured, typed AST, making it highly amenable to programmatic interaction, rendering, and analysis. While a formal release cadence is not explicitly stated, the early version number suggests active and iterative development.
Verified import paths — ran on the pinned version, not inferred.
This package targets Node.js >=18 and is primarily designed for ES module (ESM) usage. While CommonJS might technically work via transpilation or bundlers, native ESM imports are the recommended and intended way to consume this library.
The `BlockNode` type represents a parsed block-level Markdown element (e.g., heading, paragraph, list). Importing this type is useful for type-checking and understanding the structure of the AST returned by the parser.
The `InlineNode` type defines inline Markdown elements (e.g., text, emphasis, code span) which typically exist as children within `BlockNode` structures. Useful for detailed AST traversal.
This quickstart demonstrates both synchronous parsing of a complete Markdown string and the library's core feature: streaming/incremental parsing, where content is fed in chunks and finalized blocks are emitted progressively.
Breaking-change detection hasn't run for this library yet.
CVE tracking and dependency tree are planned for a later release.