Classes
TabItemOptions
dataclass
Options for tab-item directive.
TabItemOptions
dataclass Options for tab-item directive.
DirectiveOptionsAttributes
| Name | Type | Description |
|---|---|---|
selected |
bool |
Whether this tab is initially selected |
icon |
str |
Icon name to show next to tab label |
badge |
str |
Badge text (e.g., "New", "Beta", "Pro") |
disabled |
bool |
Mark tab as disabled/unavailable |
TabItemDirective
Individual tab directive (nested in tab-set).
Syntax:
:::{tab-item} Tab Title
:selected:
…
TabItemDirective
Individual tab directive (nested in tab-set).
Syntax:
:::{tab-item} Tab Title
:selected:
Tab content with full **markdown** support.
:::
Contract:
MUST be nested inside a :::{tab-set} directive.
BengalDirectiveAttributes
| Name | Type | Description |
|---|---|---|
NAMES |
ClassVar[list[str]] |
|
TOKEN_TYPE |
ClassVar[str] |
|
OPTIONS_CLASS |
ClassVar[type[DirectiveOptions]] |
|
CONTRACT |
ClassVar[DirectiveContract] |
|
DIRECTIVE_NAMES |
ClassVar[list[str]] |
Methods 2
parse_directive
Build tab-item token from parsed components.
parse_directive
def parse_directive(self, title: str, options: TabItemOptions, content: str, children: list[Any], state: Any) -> DirectiveToken
Build tab-item token from parsed components.
Parameters 5
title |
str |
|
options |
TabItemOptions |
|
content |
str |
|
children |
list[Any] |
|
state |
Any |
Returns
DirectiveToken
render
Render individual tab item to HTML.
Creates a wrapper div with metadata that t…
render
def render(self, renderer: Any, text: str, **attrs: Any) -> str
Render individual tab item to HTML.
Creates a wrapper div with metadata that the parent tab-set will parse to build the navigation and panels.
Parameters 2
renderer |
Any |
|
text |
str |
Returns
str
TabSetOptions
dataclass
Options for tab-set directive.
TabSetOptions
dataclass Options for tab-set directive.
DirectiveOptionsAttributes
| Name | Type | Description |
|---|---|---|
id |
str |
Unique ID for the tab set |
sync |
str |
Sync key for synchronizing tabs across multiple tab-sets |
TabSetDirective
Modern MyST-style tab container directive.
Syntax:
::::{tab-set}
:sync: my-key
:::{ta…
TabSetDirective
Modern MyST-style tab container directive.
Syntax:
::::{tab-set}
:sync: my-key
:::{tab-item} Python
Python content with **markdown** support.
:::
:::{tab-item} JavaScript
JavaScript content here.
:::
::::
Contract:
REQUIRES at least one :::{tab-item} child directive.
BengalDirectiveAttributes
| Name | Type | Description |
|---|---|---|
NAMES |
ClassVar[list[str]] |
|
TOKEN_TYPE |
ClassVar[str] |
|
OPTIONS_CLASS |
ClassVar[type[DirectiveOptions]] |
|
CONTRACT |
ClassVar[DirectiveContract] |
|
DIRECTIVE_NAMES |
ClassVar[list[str]] |
Methods 2
parse_directive
Build tab-set token from parsed components.
parse_directive
def parse_directive(self, title: str, options: TabSetOptions, content: str, children: list[Any], state: Any) -> DirectiveToken
Build tab-set token from parsed components.
Parameters 5
title |
str |
|
options |
TabSetOptions |
|
content |
str |
|
children |
list[Any] |
|
state |
Any |
Returns
DirectiveToken
render
Render tab-set container to HTML.
Extracts tab items from rendered children an…
render
def render(self, renderer: Any, text: str, **attrs: Any) -> str
Render tab-set container to HTML.
Extracts tab items from rendered children and builds navigation + content panels.
Parameters 2
renderer |
Any |
|
text |
str |
Returns
str
TabItemData
dataclass
Data extracted from a rendered tab-item div.
TabItemData
dataclass Data extracted from a rendered tab-item div.
Attributes
| Name | Type | Description |
|---|---|---|
title |
str |
|
selected |
str |
|
icon |
str |
|
badge |
str |
|
disabled |
str |
|
content |
str |
Functions
_extract_tab_items
Extract tab-item divs from rendered HTML, handling nested divs correctly.
_extract_tab_items
def _extract_tab_items(text: str) -> list[TabItemData]
Extract tab-item divs from rendered HTML, handling nested divs correctly.
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
text |
str |
— | Rendered HTML containing tab-item divs |
Returns
List of TabItemData with extracted attributeslist[TabItemData]
—