# math

URL: /patitas/api/roles/builtins/math/
Section: builtins
Description: Math role for inline mathematical expressions.

Provides the {math} role as an alternative to $...$ syntax.

Example:
The equation \{math}`E = mc^2` is famous.

---

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

Open LLM text
(/patitas/api/roles/builtins/math/index.txt)

Share with AI

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

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

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

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

Module

#
`roles.builtins.math`

Math role for inline mathematical expressions.

Provides the {math} role as an alternative to $...$ syntax.

Example:

The equation {math}`E = mc^2`is famous.

1Class

## Classes

`MathRole`

4

▼

Handler for \{math}`expression` role.

Renders inline mathematical expressions. The output format
d…

Handler for {math}`expression`role.

Renders inline mathematical expressions. The output format
depends on the math rendering library configured (MathJax, KaTeX, etc.).

Syntax:

```
\{math}`E = mc^2`
\{math}`\sum_{i=1}^n x_i`
```

Thread Safety:

```
Stateless handler. Safe for concurrent use.
```

#### Attributes

Name
Type
Description

`names`

`ClassVar[tuple[str, ...]]`

—

`token_type`

`ClassVar[str]`

—

#### Methods

`parse`

3

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

▼

Parse math role content.

Content is preserved as-is for math rendering.

`def parse(self, name: str, content: str, location: SourceLocation) -> Role`

##### Parameters

Name
Type
Description

`name`
`—`

`content`
`—`

`location`
`—`

##### Returns

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

`render`

2

▼

Render math expression.

Uses span with math class for CSS styling and JS rende…

`def render(self, node: Role, sb: StringBuilder) -> None`

Render math expression.

Uses span with math class for CSS styling and JS rendering.
Outputs raw LaTeX (matches plugin format) for KaTeX katex.render().

##### Parameters

Name
Type
Description

`node`
`—`

`sb`
`—`
