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.
npm install markdown-parserVerified import paths — ran on the pinned version, not inferred.
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.
To ensure all link references are correctly resolved, always feed all definition-containing chunks to the parser. Crucially, call `parser.parse('', { stream: false })` as the final step when all input has been provided to explicitly finalize the stream and allow the parser to resolve any remaining references. If displaying partial streams, handle potentially unresolved links gracefully in your rendering logic.It is strongly recommended to regularly consult the package's changelog or GitHub repository for any breaking changes before upgrading. For production environments, pinning to exact patch versions (`~0.1.x` or `0.1.x`) is advisable until a stable major release (v1.0.0) is available.
For each distinct Markdown document or stream, instantiate a new `MarkdownParser`. Reusing an instance for unrelated content after a streaming parse without full finalization can lead to corrupted ASTs due to lingering internal state.
Switch to ES module `import` syntax: `import { MarkdownParser } from 'markdown-parser';`.After providing all available input chunks, make a final call to `parser.parse('', { stream: false })` to force the parser to finalize and emit any remaining buffered blocks. This signals the end of the stream.Ensure you correctly instantiate the parser class before calling its methods: `const parser = new MarkdownParser();` then `parser.parse(...)`.
No dependency data recorded yet.