Parser
Streaming CommonMark/GFM parser.
Usage
Parser(
*,
hardbreaks=False,
smart=False,
normalize=False,
unsafe=False,
footnotes=False,
extensions=(),
options=0
)Wraps the cmark-gfm streaming parser, allowing incremental feeding of Markdown content and rendering to any output format. Useful for processing large documents or streaming input without buffering the entire source in memory.
Parameters
hardbreaks: bool = False-
Render soft line breaks as hard breaks. Default
False. smart: bool = False-
Enable smart punctuation. Default
False. normalize: bool = False-
Consolidate adjacent text nodes. Default
False. unsafe: bool = False-
Allow raw HTML passthrough. Default
False. footnotes: bool = False-
Enable footnote syntax. Default
False. extensions: Sequence[str] = ()-
GFM extensions to enable (e.g.,
["table", "strikethrough"]). options: int = 0- Raw Options bitmask, OR’d with boolean kwargs.
Examples
Basic streaming usage:
from multimark import Parser
parser = Parser(smart=True)
parser.feed("# Hello\n\n")
parser.feed("World!\n")
html = parser.render_html()Context manager:
with Parser(extensions=["table"]) as p:
p.feed("| A | B |\n|---|---|\n| 1 | 2 |\n")
html = p.render_html()