Classes
DataTableDirective
Data table directive using Mistune's fenced syntax.
Syntax:
```{data-table} path/to/data.yaml
…
DataTableDirective
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
DirectivePluginMethods 1
parse
Parse data-table directive.
parse
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
Token dict with type 'data_table'dict[str, Any]
—
Internal Methods 8
_load_data
Load data from YAML or CSV file.
Path Resolution:
- root_path MUST be prov…
_load_data
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 with 'columns' and 'data' keys, or 'error' key on failuredict[str, Any]
—
_load_yaml_data
Load data from YAML file.
Expected structure:
columns:
- title: Colu…
_load_yaml_data
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 with 'columns' and 'data' keys, or 'error' keydict[str, Any]
—
_load_csv_data
Load data from CSV file.
_load_csv_data
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 with 'columns' and 'data' keys, or 'error' keydict[str, Any]
—
_generate_table_id
Generate unique table ID from path.
_generate_table_id
def _generate_table_id(self, path: str) -> str
Generate unique table ID from path.
Parameters 1
path |
str |
File path |
Returns
Unique table IDstr
—
_parse_bool
Parse boolean option value.
_parse_bool
def _parse_bool(self, value: str) -> bool
Parse boolean option value.
Parameters 1
value |
str |
Returns
bool
_parse_pagination
Parse pagination option.
_parse_pagination
def _parse_pagination(self, value: str) -> int | bool
Parse pagination option.
Parameters 1
value |
str |
Pagination value (number or "false") |
Returns
Int for page size, False to disable paginationint | bool
—
_parse_columns
Parse visible columns option.
_parse_columns
def _parse_columns(self, value: str) -> list[str] | None
Parse visible columns option.
Parameters 1
value |
str |
Comma-separated column list |
Returns
List of column names, or None for all columnslist[str] | None
—
__call__
Register the directive and renderer.
__call__
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.
render_data_table
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
HTML string for data tablestr
—