markdown — lilu API

←index

Overview

Streaming markdown parser and renderer with support for CommonMark, GFM extensions (tables, strikethrough, autolinks, task lists), and djot features (fenced divs, inline attributes). Provides static terminal rendering via TSS, streaming terminal rendering for LLM output, and HTML5 output.

Submodules

ModuleDescription
markdown.bufferStreaming buffer for chunk boundary handling in inline parsing.
markdown.eventsCallback-based event emitter for the markdown parser.
markdown.inlineInline element parser using a two-phase opener stack approach.
markdown.parserCore streaming parser that coordinates block detection, inline parsing, and callback-based event emission.
markdown.rendererRenderer registry and factory with three implementations: static (full document rendering for pager display), streaming (live cursor-based rendering for LLM output), and html (semantic HTML5).
markdown.stateBlock state machine with pattern-based detection for CommonMark block structures: headings, code fences, thematic breaks, lists, tables, blockquotes, divs, link references, and footnotes.

Functions

NameSignature
streamstream(options) -> parser
renderrender(input, options) -> result, err
render_htmlrender_html(input, options) -> html, err
parseparse(input, options) -> events

stream(options) -> parser

Create a streaming parser instance for incremental parsing

Returns a parser instance with feed(chunk), finish(), reset(), and set_event_callback(fn) methods. Options:

render(input, options) -> result, err

Render markdown to styled terminal output

Parses and renders markdown through the named renderer. Options:

render_html(input, options) -> html, err

Render markdown to semantic HTML5

parse(input, options) -> events

Parse markdown and collect events into an array

Parses input and returns an array of event tables. Options: