Module

rendering.plugins.directives.admonitions

Admonition directive for Mistune.

Provides note, warning, tip, danger, and other callout boxes with full markdown support.

Architecture:

Migrated to BengalDirective base class as part of directive system v2.
Uses multi-name registration pattern for 10 admonition types.

Classes

AdmonitionOptions dataclass
Options for admonition directive.
0

Options for admonition directive.

Inherits from DirectiveOptions

Attributes

Name Type Description
css_class str

Additional CSS classes

_field_aliases ClassVar[dict[str, str]]
AdmonitionDirective
Admonition directive using Mistune's fenced syntax. Syntax: :::{note} Optional Title Conte…
3

Admonition directive using Mistune's fenced syntax.

Syntax:

:::{note} Optional Title
Content with **markdown** support.
:::

With custom classes:

:::{note} Optional Title
:class: holo custom-class
Content with **markdown** support.
:::

Supported types: note, tip, warning, danger, error, info, example, success, caution, seealso

Inherits from BengalDirective

Attributes

Name Type Description
NAMES ClassVar[list[str]]
TOKEN_TYPE ClassVar[str]
OPTIONS_CLASS ClassVar[type[DirectiveOptions]]
DIRECTIVE_NAMES ClassVar[list[str]]
ADMONITION_TYPES ClassVar[list[str]]

Methods 3

parse_directive
Build admonition token from parsed components. Note: The admonition type is pa…
5 DirectiveToken
def parse_directive(self, title: str, options: AdmonitionOptions, content: str, children: list[Any], state: Any) -> DirectiveToken

Build admonition token from parsed components.

Note: The admonition type is passed through state to avoid instance attribute mutation which could cause issues in concurrent scenarios.

Parameters 5
title str
options AdmonitionOptions
content str
children list[Any]
state Any
Returns

DirectiveToken

parse
Override parse to capture admonition type before calling parent. The admonitio…
3 dict[str, Any]
def parse(self, block: Any, m: Any, state: Any) -> dict[str, Any]

Override parse to capture admonition type before calling parent.

The admonition type (note, tip, warning, etc.) comes from parse_type(). State is used instead of instance attributes to avoid concurrency issues.

Parameters 3
block Any
m Any
state Any
Returns

dict[str, Any]

render
Render admonition to HTML.
2 str
def render(self, renderer: Any, text: str, **attrs: Any) -> str

Render admonition to HTML.

Parameters 2
renderer Any
text str
Returns

str

Functions

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

Render admonition icon using Phosphor icons.

Parameters 1

Name Type Default Description
icon_name str

Returns

str

render_admonition
Legacy render function for backward compatibility.
5 str
def render_admonition(renderer: Any, text: str, admon_type: str, title: str, extra_class: str = '') -> str

Legacy render function for backward compatibility.

Parameters 5

Name Type Default Description
renderer Any
text str
admon_type str
title str
extra_class str ''

Returns

str