Module

rendering.plugins.directives.data_table

Data table directive for Bengal SSG.

Provides interactive tables for hardware/software support matrices and other complex tabular data with filtering, sorting, and searching capabilities.

Classes

DataTableDirective
Data table directive using Mistune's fenced syntax. Syntax: ```{data-table} path/to/data.yaml …
9

Data table directive using Mistune's fenced syntax.

Syntax:

```{data-table} path/to/data.yaml
:search: true
:filter: true
:sort: true
:pagination: 50
:height: 400px
:columns: col1,col2,col3
```

Supports:

  • YAML files (with metadata and column definitions)
  • CSV files (auto-detect headers)
  • Interactive filtering, sorting, searching
  • Responsive design
  • Keyboard navigation
Inherits from DirectivePlugin

Methods 1

parse
Parse data-table directive.
3 dict[str, Any]
def parse(self, block: Any, m: Match[str], state: Any) -> dict[str, Any]

Parse data-table directive.

Parameters 3
block Any

Block parser

m Match[str]

Regex match object

state Any

Parser state

Returns

dict[str, Any]

Token dict with type 'data_table'

Internal Methods 8
_load_data
Load data from YAML or CSV file. Path Resolution: - root_path MUST be prov…
2 dict[str, Any]
def _load_data(self, path: str, state: Any) -> dict[str, Any]

Load data from YAML or CSV file.

Path Resolution:

  • root_path MUST be provided via state (set by rendering pipeline)
  • No fallback to Path.cwd() - eliminates CWD-dependent behavior
  • See: plan/active/rfc-path-resolution-architecture.md
Parameters 2
path str

Relative path to data file

state Any

Parser state (must contain root_path from rendering pipeline)

Returns

dict[str, Any]

Dict with 'columns' and 'data' keys, or 'error' key on failure

_load_yaml_data
Load data from YAML file. Expected structure: columns: - title: Colu…
1 dict[str, Any]
def _load_yaml_data(self, file_path: Path) -> dict[str, Any]

Load data from YAML file.

Expected structure:

columns:
  • title: Column Name field: field_name
  • title: Another Column field: another_field data:
  • field_name: value1 another_field: value2
  • field_name: value3 another_field: value4
Parameters 1
file_path Path

Path to YAML file

Returns

dict[str, Any]

Dict with 'columns' and 'data' keys, or 'error' key

_load_csv_data
Load data from CSV file.
1 dict[str, Any]
def _load_csv_data(self, file_path: Path) -> dict[str, Any]

Load data from CSV file.

Parameters 1
file_path Path

Path to CSV file

Returns

dict[str, Any]

Dict with 'columns' and 'data' keys, or 'error' key

_generate_table_id
Generate unique table ID from path.
1 str
def _generate_table_id(self, path: str) -> str

Generate unique table ID from path.

Parameters 1
path str

File path

Returns

str

Unique table ID

_parse_bool
Parse boolean option value.
1 bool
def _parse_bool(self, value: str) -> bool

Parse boolean option value.

Parameters 1
value str
Returns

bool

_parse_pagination
Parse pagination option.
1 int | bool
def _parse_pagination(self, value: str) -> int | bool

Parse pagination option.

Parameters 1
value str

Pagination value (number or "false")

Returns

int | bool

Int for page size, False to disable pagination

_parse_columns
Parse visible columns option.
1 list[str] | None
def _parse_columns(self, value: str) -> list[str] | None

Parse visible columns option.

Parameters 1
value str

Comma-separated column list

Returns

list[str] | None

List of column names, or None for all columns

__call__
Register the directive and renderer.
2 Any
def __call__(self, directive: Any, md: Any) -> Any

Register the directive and renderer.

Parameters 2
directive Any
md Any
Returns

Any

Functions

render_data_table
Render data table to HTML.
2 str
def render_data_table(renderer: Any, text: str, **attrs: Any) -> str

Render data table to HTML.

Parameters 2

Name Type Default Description
renderer Any

Mistune renderer

text str

Rendered children content (unused for data tables) **attrs: Table attributes from directive

Returns

str

HTML string for data table