# formatting

URL: /patitas/api/roles/builtins/formatting/
Section: builtins
Description: Formatting roles for inline styling.

Provides roles for common inline formatting:
- kbd: Keyboard shortcuts
- abbr: Abbreviations with expansion
- sub: Subscript
- sup: Superscript

Example:
Press \{kbd}`Ctrl+C` to copy.
The \{abbr}`HTML (HyperText Markup Language)` standard.
H\{sub}`2`O is water.
E = mc\{sup}`2`.

---

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

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

Share with AI

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

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

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

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

Module

#
`roles.builtins.formatting`

Formatting roles for inline styling.

Provides roles for common inline formatting:

- kbd: Keyboard shortcuts

- abbr: Abbreviations with expansion

- sub: Subscript

- sup: Superscript

Example:

Press {kbd}`Ctrl+C`to copy.
The {abbr}`HTML (HyperText Markup Language)`standard.
H{sub}`2`O is water.
E = mc{sup}`2`.

4Classes

## Classes

`KbdRole`

4

▼

Handler for \{kbd}`key` role.

Renders keyboard shortcuts with proper semantics.

Syntax:
\{kbd…

Handler for {kbd}`key`role.

Renders keyboard shortcuts with proper semantics.

Syntax:

```
\{kbd}`Ctrl+C` - Single shortcut
\{kbd}`Ctrl+Shift+P` - Multiple modifiers
\{kbd}`+` or \{kbd}`Plus` - The plus key itself
```

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 kbd role content.

`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 keyboard shortcut.

Wraps each key in tags for proper semantics.
Handle…

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

Render keyboard shortcut.

Wraps each key in tags for proper semantics.
Handles + as key separator, with special handling for the + key itself.

##### Parameters

Name
Type
Description

`node`
`—`

`sb`
`—`

`AbbrRole`

4

▼

Handler for \{abbr}`ABBR (expansion)` role.

Renders abbreviations with title attribute for expansi…

Handler for {abbr}`ABBR (expansion)`role.

Renders abbreviations with title attribute for expansion.

Syntax:

```
\{abbr}`HTML (HyperText Markup Language)`
```

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 abbr role content.

Extracts abbreviation and expansion from "ABBR (expan…

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

Parse abbr role content.

Extracts abbreviation and expansion from "ABBR (expansion)" format.

##### Parameters

Name
Type
Description

`name`
`—`

`content`
`—`

`location`
`—`

##### Returns

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

`render`

2

▼

Render abbreviation with title.

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

##### Parameters

Name
Type
Description

`node`
`—`

`sb`
`—`

`SubRole`

4

▼

Handler for \{sub}`text` role.

Renders subscript text.

Syntax:
H\{sub}`2`O

Thread Safety:
…

Handler for {sub}`text` (/patitas/api/text/) role.

Renders subscript text.

Syntax:

```
H\{sub}`2`O
```

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 sub role content.

`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 subscript.

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

##### Parameters

Name
Type
Description

`node`
`—`

`sb`
`—`

`SupRole`

4

▼

Handler for \{sup}`text` role.

Renders superscript text.

Syntax:
E = mc\{sup}`2`

Thread Safe…

Handler for {sup}`text` (/patitas/api/text/) role.

Renders superscript text.

Syntax:

```
E = mc\{sup}`2`
```

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 sup role content.

`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 superscript.

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

##### Parameters

Name
Type
Description

`node`
`—`

`sb`
`—`
