Module

rendering.plugins.directives.list_table

List table directive for Bengal SSG.

Provides MyST-style list-table directive for creating tables from nested lists, avoiding the pipe character collision issue in type annotations.

Classes

ListTableDirective
List table directive using MyST syntax. Syntax: :::{list-table} :header-rows: 1 :width…
3

List table directive using MyST syntax.

Syntax:

:::{list-table}
:header-rows: 1
:widths: 20 30 50

* - Header 1
  • Header 2
  • Header 3
      • Row 1, Col 1
  • Row 1, Col 2
  • Row 1, Col 3
      • Row 2, Col 1
  • Row 2, Col 2
  • Row 2, Col 3 :::

Supports:

  • :header-rows: number - Number of header rows (default: 0)
  • :widths: space-separated percentages - Column widths
  • :class: CSS class for the table
Inherits from DirectivePlugin

Methods 1

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

Parse list-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 'list_table'

Internal Methods 2
_parse_list_rows
Parse list content into table rows.
1 list[list[str]]
def _parse_list_rows(self, content: str) -> list[list[str]]

Parse list content into table rows.

Parameters 1
content str

Raw content string

Returns

list[list[str]]

List of rows, where each row is a list of cell contents

__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_list_table
Render list table to HTML.
2 str
def render_list_table(renderer: Any, text: str, **attrs: Any) -> str

Render list table to HTML.

Parameters 2

Name Type Default Description
renderer Any

Mistune renderer

text str

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

Returns

str

HTML string for list table