# llm

URL: /patitas/api/renderers/llm/
Section: renderers
Description: LLM-optimized renderer — structured plain text for model consumption.

Outputs markdown-like plain text with explicit labels for code, math, and images.
No HTML. Normalized whitespace. Predictable, parseable format.

Example:
    >>> from patitas import parse, render_llm
    >>> doc = parse("# Hello **World**\n\n- item")
    >>> render_llm(doc)
    '# Hello World\n\n- item\n'

---

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

Open LLM text
(/patitas/api/renderers/llm/index.txt)

Share with AI

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

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

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

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

Module

#
`renderers.llm`

LLM-optimized renderer — structured plain text for model consumption.

Outputs markdown-like plain text with explicit labels for code, math, and images.
No HTML. Normalized whitespace. Predictable, parseable format.

Example:

```
>>> from patitas import parse, render_llm
>>> doc = parse("# Hello **World**\n\n- item")
>>> render_llm(doc)
'# Hello World\n\n- item\n'
```

1Class1Function

## Classes

`LlmRenderer`

9

▼

Render AST to structured plain text for LLM consumption.

No HTML. Preserves hierarchy via markdown…

Render AST to structured plain text for LLM consumption.

No HTML. Preserves hierarchy via markdown-like markers.
Labels non-text content explicitly.

#### Methods

`render`

1

`str`

▼

Render document to LLM-friendly plain text.

`def render(self, node: Document) -> str`

##### Parameters

Name
Type
Description

`node`
`—`

##### Returns

`str`

Internal Methods
8

▼

`__init__`

1

▼

`def __init__(self, source: str = '') -> None`

##### Parameters

Name
Type
Description

`source`
`—`

Default:`''`

`_render_block`

2

▼

Render a block node.

`def _render_block(self, block, sb: StringBuilder) -> None`

##### Parameters

Name
Type
Description

`block`
`—`

`sb`
`—`

`_render_list_item`

2

▼

Render list item content.

`def _render_list_item(self, item: ListItem, sb: StringBuilder) -> None`

##### Parameters

Name
Type
Description

`item`
`—`

`sb`
`—`

`_render_table`

2

▼

Render table as markdown-style grid.

`def _render_table(self, table: Table, sb: StringBuilder) -> None`

##### Parameters

Name
Type
Description

`table`
`—`

`sb`
`—`

`_inline_text`

1

`str`

▼

Extract plain text from a node with inline children.

`def _inline_text(self, node) -> str`

##### Parameters

Name
Type
Description

`node`
`—`

##### Returns

`str`

`_render_inlines`

2

▼

Render inline nodes.

`def _render_inlines(self, inlines: tuple[Inline, ...], sb: StringBuilder) -> None`

##### Parameters

Name
Type
Description

`inlines`
`—`

`sb`
`—`

`_render_inline`

2

▼

Render a single inline node.

`def _render_inline(self, inline: Inline, sb: StringBuilder) -> None`

##### Parameters

Name
Type
Description

`inline`
`—`

`sb`
`—`

`_inline_text_single`

1

`str`

▼

Extract plain text from one inline (for table cells).

`def _inline_text_single(self, inline: Inline) -> str`

##### Parameters

Name
Type
Description

`inline`
`—`

##### Returns

`str`

## Functions

`render_llm`

2

`str`

▼

Render document to LLM-friendly plain text.

`def render_llm(doc: Document, *, source: str = '') -> str`

##### Parameters

Name
Type
Description

`doc`
`Document (/patitas/api/nodes/#Document)`

Document AST to render.

`source`
`str`

Original source (for FencedCode zero-copy extraction).

Default:`''`

##### Returns

`str`
