# text

URL: /patitas/api/text/
Section: api
Description: Extract plain text from Patitas AST nodes.

Provides a public API for extracting text content from any node type,
used for heading slugs, excerpts, and LLM-safe text rendering.

Example:
    >>> from patitas import parse, extract_text
    >>> doc = parse("# Hello **World**")
    >>> extract_text(doc.children[0])
    'Hello World'

---

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

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

Share with AI

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

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

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

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

Module

#
`text`

Extract plain text from Patitas AST nodes.

Provides a public API for extracting text content from any node type,
used for heading slugs, excerpts, and LLM-safe text rendering.

Example:

```
>>> from patitas import parse, extract_text
>>> doc = parse("# Hello **World**")
>>> extract_text(doc.children[0])
'Hello World'
```

1Function

## Functions

`extract_text`

2

`str`

▼

Extract plain text from any AST node.

Recursively walks the tree, concatenatin…

`def extract_text(node: Node, *, source: str = '') -> str`

Extract plain text from any AST node.

Recursively walks the tree, concatenating text content. Skips HtmlBlock,
HtmlInline. LineBreak and SoftBreak contribute a space.

##### Parameters

Name
Type
Description

`node`
`Node (/patitas/api/nodes/#Node)`

Any AST node (block or inline).

`source`
`str`

Original source string (required for FencedCode zero-copy extraction; use empty string if unavailable).

Default:`''`

##### Returns

`str`
