{"library":"markdown-parser","title":"Streaming Markdown Parser","description":"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.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install markdown-parser"],"cli":null},"imports":["import { MarkdownParser } from 'markdown-parser';","import type { BlockNode } from 'markdown-parser';","import type { InlineNode } from 'markdown-parser';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { MarkdownParser } from \"markdown-parser\";\nimport type { BlockNode } from \"markdown-parser\";\n\nconst parser = new MarkdownParser();\n\n// Example 1: Parse complete markdown in one go\nconst completeNodes: BlockNode[] = parser.parse(\"# Hello World\\nThis is a paragraph.\");\nconsole.log('Complete Parse Output:', JSON.stringify(completeNodes, null, 2));\n// Expected: [\n//   { type: \"heading\", level: 1, children: [{ type: \"text\", text: \"Hello World\" }] },\n//   { type: \"paragraph\", children: [{ type: \"text\", text: \"This is a paragraph.\" }] }\n// ]\n\n// Example 2: Parse with streaming mode for incremental content\nconsole.log('\\n--- Streaming Parse ---');\nlet streamOutput1: BlockNode[] = parser.parse(\"# Hello World\\nThis\", { stream: true });\nconsole.log('Stream Part 1:', JSON.stringify(streamOutput1, null, 2));\n// Expected: [\n//   { type: \"heading\", level: 1, children: [{ type: \"text\", text: \"Hello World\" }] }\n// ] (paragraph is still open)\n\nlet streamOutput2: BlockNode[] = parser.parse(\" is a paragraph\\n\\nThis is another paragraph.\", { stream: true });\nconsole.log('Stream Part 2:', JSON.stringify(streamOutput2, null, 2));\n// Expected: [\n//   { type: \"paragraph\", children: [{ type: \"text\", text: \"This is a paragraph.\" }] }\n// ] (second paragraph still open)\n\nlet streamOutput3: BlockNode[] = parser.parse(\"\", { stream: false }); // Finalize the stream\nconsole.log('Stream Finalize:', JSON.stringify(streamOutput3, null, 2));\n// Expected: [\n//   { type: \"paragraph\", children: [{ type: \"text\", text: \"This is another paragraph.\" }] }\n// ]\n\nconsole.log('\\n--- End Streaming Parse ---');\n","lang":"typescript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}