markdown.tightness

index ยท markdown

Overview

Event filter that resolves CommonMark list tightness exactly.

A list is loose when a blank line separates any two of its blocks, which the parser can only discover after the list has already started. It says so after the fact, with a list_loose event, and leaves the provisional tight = true on the list's block_start alone.

This filter buffers a top-level list subtree until it closes, back-patches each block_start with the looseness its list_loose events reported, and only then replays the events downstream. Consumers therefore see the final answer on the list's block_start, at the cost of holding one list subtree in memory. Realtime consumers should skip the filter and act on the list_loose events directly instead.

Functions

NameSignature
newnew(on_event) -> filter

new(on_event) -> filter

Create a list tightness filter

Returns a filter with feed(event), finish(), and reset() methods. on_event receives the resolved event stream.