Module

parsing.blocks.quote_token_reuse

Token-reuse block quote parsing.

Instead of collecting strings and re-tokenizing, this approach directly interprets existing tokens for block quote content.

This eliminates the re-tokenization overhead for block quotes.

Functions

can_use_token_reuse 2 bool
Check if block quote can use token reuse optimization. **Criteria:** 1. Conten…
def can_use_token_reuse(tokens: list, start_pos: int) -> bool

Check if block quote can use token reuse optimization.

Criteria:

  1. Content is simple paragraphs only (no code blocks, lists, etc.)
  2. No lazy continuation (every content line follows a BLOCK_QUOTE_MARKER)
  3. No nested block quotes (>> pattern)
Parameters
Name Type Description
tokens list

Full token list

start_pos int

Position of first BLOCK_QUOTE_MARKER

Returns
bool
parse_blockquote_with_token_reuse 3 tuple[BlockQuote, int]
Parse block quote by reusing existing tokens. PRECONDITION: can_use_token_reus…
def parse_blockquote_with_token_reuse(tokens: list, start_pos: int, parse_inline_fn: Callable[[str, SourceLocation], tuple[Inline, ...]]) -> tuple[BlockQuote, int]

Parse block quote by reusing existing tokens.

PRECONDITION: can_use_token_reuse(tokens, start_pos) returned True.

Parameters
Name Type Description
tokens list

Full token list

start_pos int

Position of first BLOCK_QUOTE_MARKER

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

Function to parse inline content

Returns
tuple[BlockQuote, int]
_is_complex_blockquote_content 1 bool
Check if content requires full sub-parser.
def _is_complex_blockquote_content(content: str) -> bool
Parameters
Name Type Description
content str
Returns
bool