Updated
On this page
Render structured data as Markdown tables with column alignment, pretty-printed output, and automatic pipe escaping for safe embedding in documentation.
#selfdoc.tables
#selfdoc.tables
Render data as Markdown tables with alignment, pretty-printing, and pipe escaping.
#_escape_pipes
python
def _escape_pipes(text)Escape pipe characters in text, preserving pipes inside backtick spans.
If a backtick opens a span but never closes, pipes after the unclosed backtick are escaped as if the span never opened.
#render_markdown_table
python
def render_markdown_table(headers, rows, *, align=None, pretty=False)Render a Markdown table from headers and rows.
Parameters: headers: Column header labels. rows: Each inner list is one row of cell values. align: Per-column alignment ("left", "center", "right"), or None. pretty: If True, pad cells for visual alignment.
Returns:
- Complete markdown table string.
Raises:
ValueError: If a cell contains a newline, or a row has more cells
than headers, or align contains an invalid value.