# nested

URL: /patitas/api/parsing/blocks/list/nested/
Section: list
Description: Nested list handling for list parsing.

Handles detection and parsing of nested lists within list items.

---

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

Open LLM text
(/patitas/api/parsing/blocks/list/nested/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%2Fnested%2Findex.txt)

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

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

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

Module

#
`parsing.blocks.list.nested`

Nested list handling for list parsing.

Handles detection and parsing of nested lists within list items.

6Functions

## Functions

`detect_nested_block_in_content`

3

`bool`

▼

Detect if paragraph line content is actually a nested block marker.

CommonMark…

`def detect_nested_block_in_content(line: str, line_indent: int, content_indent: int) -> bool`

Detect if paragraph line content is actually a nested block marker.

CommonMark: If the first content after a list marker is itself a block
marker (list, blockquote, heading, etc.), it should be parsed as a nested
block, BUT only if it's indented appropriately (not 4+ spaces beyond
content indent).

##### Parameters

Name
Type
Description

`line`
`str`

The stripped line content

`line_indent`
`int`

Indent of the line (from tok.line_indent)

`content_indent`
`int`

Content indent of the current list item

##### Returns

`bool`

`parse_nested_list_inline`

3

`list[Block]`

▼

Parse a nested list from inline content.

Used when a paragraph line turns out …

`def parse_nested_list_inline(line: str, token_location: object, parser: ParserProtocol) -> list[Block]`

Parse a nested list from inline content.

Used when a paragraph line turns out to be a nested list marker.
Configuration is automatically inherited via ContextVar—no copying needed!

Thread Safety:
Nested parser reads config from the same ContextVar as parent,
ensuring consistent configuration without manual copying.

##### Parameters

Name
Type
Description

`line`
`str`

The content line that is a list marker

`token_location`
`object`

Location of the token

`parser`
`ParserProtocol`

The parser instance

##### Returns

`list[Block]`

`parse_nested_list_from_indented_code`

4

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

▼

Parse a nested list from an INDENTED_CODE token, guarding nesting depth.

Thin …

`def parse_nested_list_from_indented_code(token: Token, original_indent: int, parent_content_indent: int, parser: ParserProtocol) -> List | None`

Parse a nested list from an INDENTED_CODE token, guarding nesting depth.

Thin wrapper around the implementation that bounds recursion depth. This
function recurses once per deeper nested level, so adversarially deep
indented-code list nesting would otherwise crash with an uncaught
`RecursionError`. Raises a catchable `ParseError` (/patitas/api/errors/#ParseError) past the limit.

##### Parameters

Name
Type
Description

`token`
`Token (/patitas/api/tokens/#Token)`

`original_indent`
`int`

`parent_content_indent`
`int`

`parser`
`ParserProtocol`

##### Returns

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

`_parse_nested_list_from_indented_code_impl`

4

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

▼

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

When…

`def _parse_nested_list_from_indented_code_impl(token: Token, original_indent: int, parent_content_indent: int, parser: ParserProtocol) -> List | None`

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

When the lexer produces INDENTED_CODE for 4+ space indented lines, those
lines may actually be nested list markers in list context.

##### Parameters

Name
Type
Description

`token`
`Token (/patitas/api/tokens/#Token)`

The INDENTED_CODE token containing the list marker

`original_indent`
`int`

The original indentation of the line in source

`parent_content_indent`
`int`

The content indent of the parent list item

`parser`
`ParserProtocol`

The parser instance

##### Returns

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

`_is_sibling_marker`

5

`bool`

▼

Check if content is a sibling list marker at the expected indent.

`def _is_sibling_marker(content: str, content_indent: int, expected_indent: int, ordered: bool, marker_char: str) -> bool`

##### Parameters

Name
Type
Description

`content`
`str`

`content_indent`
`int`

`expected_indent`
`int`

`ordered`
`bool`

`marker_char`
`str`

##### Returns

`bool`

`_extract_remaining_content`

2

`str`

▼

Extract content after the list marker.

`def _extract_remaining_content(content: str, ordered: bool) -> str`

##### Parameters

Name
Type
Description

`content`
`str`

`ordered`
`bool`

##### Returns

`str`
