Module

rendering.plugins.directives.code_tabs

Code tabs directive for Mistune.

Provides multi-language code examples with tabbed interface for easy comparison across programming languages.

Architecture:

Migrated to BengalDirective base class as part of directive system v2.

Classes

CodeTabsOptions dataclass
Options for code-tabs directive (currently none).
0

Options for code-tabs directive (currently none).

Inherits from DirectiveOptions
CodeTabsDirective
Code tabs for multi-language examples. Syntax: ````{code-tabs} ### Tab: Python ```pyt…
2

Code tabs for multi-language examples.

Syntax:

````{code-tabs}

### Tab: Python
```python
# Example code here
```

### Tab: JavaScript
```javascript
console.log("hello")
```
````

Aliases: code-tabs, code_tabs

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]]

Methods 2

parse_directive
Build code tabs token by parsing tab markers in content. Note: Returns dict in…
5 dict[str, Any]
def parse_directive(self, title: str, options: CodeTabsOptions, content: str, children: list[Any], state: Any) -> dict[str, Any]

Build code tabs token by parsing tab markers in content.

Note: Returns dict instead of DirectiveToken because children are custom code_tab_item tokens, not parsed markdown.

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

dict[str, Any]

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

Render code tabs to HTML.

Parameters 2
renderer Any
text str
Returns

str

Functions

render_code_tabs
Legacy render function for backward compatibility.
2 str
def render_code_tabs(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

render_code_tab_item
Render code tab item marker (used internally).
1 str
def render_code_tab_item(renderer: Any, **attrs: Any) -> str

Render code tab item marker (used internally).

Parameters 1

Name Type Default Description
renderer Any

Returns

str