Module

parsing.backends.patitas.directives.builtins.admonition

Admonition directive for callout boxes.

Supports standard admonition types:

  • note: General information
  • warning: Potential issues
  • tip: Helpful suggestions
  • danger: Serious risk
  • error: Error conditions
  • info: Informational callout
  • example: Example content
  • success: Success messages
  • caution: Proceed carefully (maps to warning CSS)
  • seealso: Related information

Example:

Optional Title

This is the note content.

Thread Safety:

Stateless handler. Safe for concurrent use across threads.

HTML Output:

Matches Bengal's admonition directive exactly:

{SVG} Title

{content}

Classes

AdmonitionDirective 6
Handler for admonition directives. Renders callout boxes for notes, warnings, tips, etc. Produces …

Handler for admonition directives.

Renders callout boxes for notes, warnings, tips, etc. Produces HTML identical to Bengal's admonition directive.

Thread Safety:

Stateless handler. Safe for concurrent use.

Attributes

Name Type Description
names ClassVar[tuple[str, ...]]
token_type ClassVar[str]
contract ClassVar[DirectiveContract | None]
options_class ClassVar[type[AdmonitionOptions]]

Methods

parse 6 Directive
Build admonition AST node.
def parse(self, name: str, title: str | None, options: AdmonitionOptions, content: str, children: Sequence[Block], location: SourceLocation) -> Directive
Parameters
Name Type Description
name

Admonition type (note, warning, etc.)

title

Custom title (uses type name if None)

options

Typed admonition options

content

Raw content (unused, prefer children)

children

Parsed child blocks

location

Source location

Returns
Directive Directive node for AST
render 3
Render admonition to HTML. Produces HTML matching Bengal's admonition directiv…
def render(self, node: Directive[AdmonitionOptions], rendered_children: str, sb: StringBuilder) -> None

Render admonition to HTML.

Produces HTML matching Bengal's admonition directive exactly, including icon wrapper structure.

Parameters
Name Type Description
node

Directive AST node

rendered_children

Pre-rendered child content

sb

StringBuilder for output

Functions

_render_admonition_icon 1 str
Render admonition icon using Phosphor icons.
def _render_admonition_icon(icon_name: str) -> str
Parameters
Name Type Description
icon_name str

Name of the icon to render

Returns
str