Expand description
Canonical pipe-table structure detection and fenced-code-block tracking for raw markdown source.
Both the streaming controller (streaming/controller.rs) and the
markdown-fence unwrapper (markdown.rs) need to identify pipe-table
structure and fenced code blocks in raw markdown source. This module
provides the canonical implementations so fixes only need to happen in one
place.
§Concepts
A GFM pipe table is a sequence of lines where:
- A header line contains pipe-separated segments with at least one non-empty cell.
- A delimiter line immediately follows the header and contains only
alignment markers (
---,:---,---:,:---:), each with at least three dashes. - Body rows follow the delimiter.
A fenced code block starts with 3+ backticks or tildes and ends with a
matching close marker. FenceTracker classifies each line as
FenceKind::Outside, FenceKind::Markdown, or FenceKind::Other
so callers can skip pipe characters that appear inside non-markdown fences.
The table functions operate on single lines and do not maintain cross-line state. Callers (the streaming controller and fence unwrapper) are responsible for pairing consecutive lines to confirm a table.
Structs§
- Fence
Tracker - Incremental tracker for fenced-code-block open/close transitions.
Enums§
- Fence
Kind - Where a source line sits relative to fenced code blocks.
Functions§
- is_
markdown_ fence_ info - Whether the info string after a fence marker indicates markdown content.
- is_
table_ delimiter_ line - Whether
lineis a valid table delimiter row (every segment passes [is_table_delimiter_segment]). - is_
table_ header_ line - Whether
linelooks like a table header row (has pipe-separated segments with at least one non-empty cell). - parse_
fence_ marker - Return fence marker character and run length for a potential fence line.
- parse_
table_ segments - Split a pipe-delimited line into trimmed segments.
- strip_
blockquote_ prefix - Peel all leading
>blockquote markers from a line.