Classes
ExampleLabelOptions
dataclass
Options for example-label directive.
ExampleLabelOptions
dataclass Options for example-label directive.
DirectiveOptionsAttributes
| Name | Type | Description |
|---|---|---|
css_class |
str |
Additional CSS classes |
prefix |
str |
Custom prefix text (default: "Example") |
no_prefix |
bool |
If true, don't show the prefix |
_field_aliases |
ClassVar[dict[str, str]] |
ExampleLabelDirective
Example label directive for lightweight example section headers.
Syntax:
:::{example-label} Ti…
ExampleLabelDirective
Example label directive for lightweight example section headers.
Syntax:
:::{example-label} Title Text
:::
With options:
:::{example-label} API Usage
:prefix: Demo
:class: featured
:::
Creates a semantic label that looks like a soft header but doesn't appear in TOC. Lighter weight than admonition callouts, perfect for example sections.
Renders immediately with no content inside - any content is ignored.
BengalDirectiveAttributes
| Name | Type | Description |
|---|---|---|
NAMES |
ClassVar[list[str]] |
|
TOKEN_TYPE |
ClassVar[str] |
|
OPTIONS_CLASS |
ClassVar[type[DirectiveOptions]] |
|
DIRECTIVE_NAMES |
ClassVar[list[str]] |
Methods 2
parse_directive
Build example label token from parsed components.
Example labels are label-onl…
parse_directive
def parse_directive(self, title: str, options: ExampleLabelOptions, content: str, children: list[Any], state: Any) -> DirectiveToken
Build example label token from parsed components.
Example labels are label-only - children are always empty.
Parameters 5
title |
str |
|
options |
ExampleLabelOptions |
|
content |
str |
|
children |
list[Any] |
|
state |
Any |
Returns
DirectiveToken
render
Render example label to HTML.
Renders as a styled paragraph with role="heading…
render
def render(self, renderer: Any, text: str, **attrs: Any) -> str
Render example label to HTML.
Renders as a styled paragraph with role="heading" for accessibility. Uses aria-level="6" to not interfere with document outline (lower than rubric's 5).
Parameters 2
renderer |
Any |
|
text |
str |
Returns
str
Functions
render_example_label
Legacy render function for backward compatibility.
render_example_label
def render_example_label(renderer: Any, text: str, **attrs: Any) -> str
Legacy render function for backward compatibility.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
renderer |
Any |
— | |
text |
str |
— |
Returns
str