# mixin

URL: /patitas/api/parsing/blocks/list/mixin/
Section: list
Description: Main list parsing mixin.

Provides the ListParsingMixin class that orchestrates list parsing
using the modular helper functions.

---

> For a complete page index, fetch /patitas/llms.txt.

Open LLM text
(/patitas/api/parsing/blocks/list/mixin/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fparsing%2Fblocks%2Flist%2Fmixin%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fparsing%2Fblocks%2Flist%2Fmixin%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fparsing%2Fblocks%2Flist%2Fmixin%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fparsing%2Fblocks%2Flist%2Fmixin%2Findex.txt)

Module

#
`parsing.blocks.list.mixin`

Main list parsing mixin.

Provides the ListParsingMixin class that orchestrates list parsing
using the modular helper functions.

1Class

## Classes

`ListParsingMixin`

12

▼

Mixin for list parsing.

Handles nested lists, task lists, continuation paragraphs, and loose/tight…

Mixin for list parsing.

Handles nested lists, task lists, continuation paragraphs, and loose/tight detection.

Required Host Attributes:

- _source: str

- _tokens: list[Token]

- _pos: int

- _current: Token | None

- _containers: ContainerStack (Phase 2 shadow stack)

Required Host Methods:

- _at_end() -> bool

- _advance() -> Token | None

- _parse_inline(text, location) -> tuple[Inline, ...]

- _parse_block() -> Block | None

- _get_line_at(offset) -> str

- _line_start_for_offset(offset: int) -> int

- _strip_columns(text, count) -> str

#### Attributes

Name
Type
Description

`_source`

`str`

—

`_tokens`

`list[Token (/patitas/api/tokens/#Token)]`

—

`_pos`

`int`

—

`_current`

`Token (/patitas/api/tokens/#Token) | None`

—

`_containers`

`ContainerStack (/patitas/api/parsing/containers/#ContainerStack)`

—

#### Methods

Internal Methods
7

▼

`_parse_list`

1

`List (/patitas/api/nodes/#List)`

▼

Parse list (unordered or ordered) with nested list support.

**Handles:**
- Nes…

`def _parse_list(self: ParserHost, parent_indent: int = -1) -> List`

Parse list (unordered or ordered) with nested list support.

Handles:

- Nested lists via indentation tracking

- Task lists with [ ] and [x] markers

- Multi-line list items (continuation paragraphs)

- Loose lists (blank lines between items)

##### Parameters

Name
Type
Description

`parent_indent`
`—`

Indent level of parent list (-1 for top-level)

Default:`-1`

##### Returns

`List (/patitas/api/nodes/#List)`

`_parse_list_item`

7

`ListItem (/patitas/api/nodes/#ListItem)`

▼

Parse a single list item, guarding against deep nesting.

Lists recurse in-pars…

`def _parse_list_item(self: ParserHost, marker_token: Token, start_indent: int, content_indent: int, ordered: bool, bullet_char: str, ordered_marker_char: str, marker_stripped: str) -> ListItem`

Parse a single list item, guarding against deep nesting.

Lists recurse in-parser (item content can contain further lists), so
a depth counter on the parser instance bounds nesting here the same way
`_parse_nested_content` (/patitas/api/parser/#Parser) bounds block-quote nesting. Adversarially deep
input raises a catchable `ParseError` (/patitas/api/errors/#ParseError) instead of an uncaught
`RecursionError`.

##### Parameters

Name
Type
Description

`marker_token`
`—`

`start_indent`
`—`

`content_indent`
`—`

`ordered`
`—`

`bullet_char`
`—`

`ordered_marker_char`
`—`

`marker_stripped`
`—`

##### Returns

`ListItem (/patitas/api/nodes/#ListItem)`

`_parse_list_item_impl`

7

`ListItem (/patitas/api/nodes/#ListItem)`

▼

Parse a single list item.

Phase 3.2: Uses stack-based loose detection. Loosene…

`def _parse_list_item_impl(self: ParserHost, marker_token: Token, start_indent: int, content_indent: int, ordered: bool, bullet_char: str, ordered_marker_char: str, marker_stripped: str) -> ListItem`

Parse a single list item.

Phase 3.2: Uses stack-based loose detection. Looseness is marked on
the current frame via mark_loose() and propagates to the parent on pop().

##### Parameters

Name
Type
Description

`marker_token`
`—`

`start_indent`
`—`

`content_indent`
`—`

`ordered`
`—`

`bullet_char`
`—`

`ordered_marker_char`
`—`

`marker_stripped`
`—`

##### Returns

`ListItem (/patitas/api/nodes/#ListItem)`

ListItem node

`_calculate_actual_content_indent`

2

`int`

▼

Calculate actual content indent from first content line.

CommonMark: The conte…

`def _calculate_actual_content_indent(self: TokenNavHost, tok: Token, marker_stripped: str) -> int`

Calculate actual content indent from first content line.

CommonMark: The content indent is the column position where the first
non-space character appears after the marker. For continuation lines,
content must be indented to at least this column.

For example, in "1. a", the marker "1." ends at column 2, followed by
a space, so content starts at column 3. Content indent = 3.

##### Parameters

Name
Type
Description

`tok`
`—`

`marker_stripped`
`—`

##### Returns

`int`

`_handle_indented_code_in_item`

4

`str | tuple[list[str], l…`

▼

Handle INDENTED_CODE token within a list item.

Phase 4: Uses container stack a…

`def _handle_indented_code_in_item(self: ParserHost, tok: Token, marker_token: Token, content_lines: list[str], item_children: list[Block]) -> str | tuple[list[str], list[Block]]`

Handle INDENTED_CODE token within a list item.

Phase 4: Uses container stack as source of truth for indent context.
The stack's content_indent is updated when actual_content_indent is
determined, so current().content_indent reflects the correct value.

##### Parameters

Name
Type
Description

`tok`
`—`

The INDENTED_CODE token

`marker_token`
`—`

The list item's marker token (for location info)

`content_lines`
`—`

Current content lines being accumulated

`item_children`
`—`

Current block children of the item

##### Returns

`str | tuple[list[str], list[Block]]`

"break" - break out of item loop
"continue" - continue to next iteration
(content_lines, item_children) - updated state

`_get_marker_indent`

1

`int`

▼

Extract indent level from list marker value.

Marker values are prefixed with s…

`def _get_marker_indent(self, marker_value: str) -> int`

Extract indent level from list marker value.

Marker values are prefixed with spaces by the lexer to encode indent.

##### Parameters

Name
Type
Description

`marker_value`
`—`

##### Returns

`int`

`_parse_nested_list_from_indented_code`

3

`List (/patitas/api/nodes/#List) | None`

▼

Parse a nested list from an INDENTED_CODE token containing a list marker.

`def _parse_nested_list_from_indented_code(self: ParserHost, token: Token, original_indent: int, parent_content_indent: int) -> List | None`

##### Parameters

Name
Type
Description

`token`
`—`

`original_indent`
`—`

`parent_content_indent`
`—`

##### Returns

`List (/patitas/api/nodes/#List) | None`
