Classes
ListParsingMixin
11
▼
Mixin for list parsing.
Handles nested lists, task lists, continuation paragraphs, and loose/tight…
ListParsingMixin
11
▼
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
- _strip_columns(text, count) -> str
Attributes
| Name | Type | Description |
|---|---|---|
_source |
str
|
— |
_tokens |
list
|
— |
_pos |
int
|
— |
_current |
Token | None
|
— |
_containers |
ContainerStack
|
— |
Methods
Internal Methods 6 ▼
_parse_list
1
List
▼
Parse list (unordered or ordered) with nested list support.
**Handles:**
- Nes…
_parse_list
1
List
▼
def _parse_list(self, 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
_parse_list_item
7
ListItem
▼
Parse a single list item.
Phase 3.2: Uses stack-based loose detection. Loosene…
_parse_list_item
7
ListItem
▼
def _parse_list_item(self, 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
ListItem node
_calculate_actual_content_indent
2
int
▼
Calculate actual content indent from first content line.
CommonMark: The conte…
_calculate_actual_content_indent
2
int
▼
def _calculate_actual_content_indent(self, 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…
_handle_indented_code_in_item
4
str | tuple[list[str], l…
▼
def _handle_indented_code_in_item(self, 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…
_get_marker_indent
1
int
▼
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 | None
▼
Parse a nested list from an INDENTED_CODE token containing a list marker.
_parse_nested_list_from_indented_code
3
List | None
▼
def _parse_nested_list_from_indented_code(self, token: Token, original_indent: int, parent_content_indent: int) -> List | None
Parameters
| Name | Type | Description |
|---|---|---|
token |
— |
|
original_indent |
— |
|
parent_content_indent |
— |
Returns
List | None