Skip to main content

Module table_detect

Module table_detect 

Source
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§

FenceTracker
Incremental tracker for fenced-code-block open/close transitions.

Enums§

FenceKind
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 line is a valid table delimiter row (every segment passes [is_table_delimiter_segment]).
is_table_header_line
Whether line looks 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.