# roles

URL: /patitas/api/roles/
Section: roles
Description: Role system for Patitas.

Provides extensible inline markup through the role syntax:

\{role}`content`

Roles are the inline equivalent of directives, providing
custom inline markup capabilities.

Key components:
- RoleHandler: Protocol for custom role implementations
- RoleRegistry: Handler lookup and registration

Thread Safety:
All components are designed for thread-safety:
- Handlers must be stateless
- Registry is immutable after creation

Example:
    >>> from patitas.roles import RoleHandler
    >>>
    >>> class EmojiRole:
    ...     names = ("emoji",)
    ...     token_type = "emoji"
    ...
    ...     def parse(self, name, content, location):
    ...         return Role(location, name, content)
    ...
    ...     def render(self, node, sb):
    ...         sb.append(f'<span class="emoji">{EMOJI_MAP.get(node.content, node.content)}</span>')

---

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

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

Share with AI

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

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

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

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

Module

#
`roles`

Role system for Patitas.

Provides extensible inline markup through the role syntax:

{role}`content`

Roles are the inline equivalent of directives, providing
custom inline markup capabilities.

Key components:

- RoleHandler: Protocol for custom role implementations

- RoleRegistry: Handler lookup and registration

Thread Safety:

All components are designed for thread-safety:

- Handlers must be stateless

- Registry is immutable after creation

Example:

```
>>> from patitas.roles import RoleHandler
>>>
>>> class EmojiRole:
...     names = ("emoji",)
...     token_type = "emoji"
...
...     def parse(self, name, content, location):
...         return Role(location, name, content)
...
...     def render(self, node, sb):
...         sb.append(f'<span class="emoji">{EMOJI_MAP.get(node.content, node.content)}</span>')
```
