Module

parsing.blocks.list.fast_path

Fast path for simple list parsing.

Bypasses the complex general-purpose list parsing logic for simple cases.

Simple List Criteria (v2 - Extended):

  1. All items use the same marker type (all-, all *, or all 1.)
  2. All items start at column 0 (no nesting from parent)
  3. No blank lines between items (tight list) OR single blank between items (uniform)
  4. Each item contains only PARAGRAPH_LINE tokens (no sub-blocks)
  5. No nested list markers in content
  6. No HTML-like content (no<at start of paragraph)
  7. No code fence markers in content
  8. No block quote markers in content

Performance: ~30-50% improvement for list-heavy documents.

Functions

is_simple_list 2 bool
Check if the list starting at start_pos qualifies for fast path. Pre-scans tok…
def is_simple_list(tokens: list, start_pos: int) -> bool

Check if the list starting at start_pos qualifies for fast path.

Pre-scans tokens to determine if all criteria are met. This is O(n) but much cheaper than the full parse decision tree.

Parameters
Name Type Description
tokens list

Full token list

start_pos int

Position of first LIST_ITEM_MARKER token

Returns
bool
parse_simple_list 3 tuple[List, int]
Parse a simple list using the fast path. PRECONDITION: is_simple_list(tokens, …
def parse_simple_list(tokens: list, start_pos: int, parse_inline_fn: Callable[[str, SourceLocation], tuple[Inline, ...]]) -> tuple[List, int]

Parse a simple list using the fast path.

PRECONDITION: is_simple_list(tokens, start_pos) returned True.

Parameters
Name Type Description
tokens list

Full token list

start_pos int

Position of first LIST_ITEM_MARKER token

parse_inline_fn Callable[[str, SourceLocation], tuple[Inline, ...]]

Function to parse inline content

Returns
tuple[List, int]
_is_complex_content 1 bool
Check if paragraph content requires complex parsing. Returns True if content c…
def _is_complex_content(content: str) -> bool

Check if paragraph content requires complex parsing.

Returns True if content contains patterns that need special handling.

Parameters
Name Type Description
content str
Returns
bool