Classes
ButtonOptions
dataclass
Options for button directive.
ButtonOptions
dataclass Options for button directive.
DirectiveOptionsAttributes
| Name | Type | Description |
|---|---|---|
color |
str |
Button color theme (primary, secondary, success, danger, etc.) |
style |
str |
Button style (default, pill, outline) |
size |
str |
Button size (small, medium, large) |
icon |
str |
Optional icon name |
target |
str |
Link target (_blank for external links) |
_allowed_values |
ClassVar[dict[str, list[str]]] |
ButtonDirective
Button directive for creating styled link buttons.
Syntax:
:::{button} /path/to/page/
:col…
ButtonDirective
Button directive for creating styled link buttons.
Syntax:
:::{button} /path/to/page/
:color: primary
:style: pill
:size: large
:icon: rocket
:target: _blank
Button Text
:::
Options:
color: primary, secondary, success, danger, warning, info, light, dark
style: default (rounded), pill (fully rounded), outline
size: small, medium (default), large
icon: Icon name (same as cards)
target: _blank for external links (optional)
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 button token from parsed components.
Title is the URL, content is the bu…
parse_directive
def parse_directive(self, title: str, options: ButtonOptions, content: str, children: list[Any], state: Any) -> DirectiveToken
Build button token from parsed components.
Title is the URL, content is the button text. Note: Uses 'label' instead of 'text' to avoid conflict with mistune's render signature which passes text as positional argument.
Parameters 5
title |
str |
|
options |
ButtonOptions |
|
content |
str |
|
children |
list[Any] |
|
state |
Any |
Returns
DirectiveToken
render
Render button as HTML link.
Renders as an <a> tag with button styling classes.…
render
def render(self, renderer: Any, text: str, **attrs: Any) -> str
Render button as HTML link.
Renders as an <a> tag with button styling classes.
Note: Button text is in attrs['label'] (not 'text') to avoid conflict with mistune's render signature.
Parameters 2
renderer |
Any |
|
text |
str |
Returns
str
Internal Methods 1
_render_icon
staticmethod
Render icon for button using Bengal SVG icons.
_render_icon
staticmethod def _render_icon(icon_name: str, button_text: str = '') -> str
Render icon for button using Bengal SVG icons.
Parameters 2
icon_name |
str |
Name of the icon to render |
button_text |
str |
Button text (for warning context) |
Returns
SVG HTML string, or empty string if not foundstr
—
Functions
render_button
Legacy render function for backward compatibility.
render_button
def render_button(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