Tables: Fold-aware Markdown table rendering#
The upstream tables renderer sizes a column from its serialized Markdown. That makes a
link destination, image URL, or other typically-hidden inline material widen every other cell.
This module keeps table serialization untouched while sizing cells from a view that folds only
that hidden material – destinations, targets, and escapes; rendered markup (emphasis, code,
math, HTML) still counts at its serialized width. CellFolder is deliberately a small
registry alongside the parser, renderer, and postprocessor registries: dialects can teach table
layout about a new hidden token without adding conditionals to the table renderer.
Fold-aware Markdown table rendering.
The upstream tables renderer sizes a column from its serialized Markdown. That makes a
link destination, image URL, or other typically-hidden inline material widen every other cell.
This module keeps table serialization untouched while sizing cells from a view that folds only
that hidden material – destinations, targets, and escapes; rendered markup (emphasis, code,
math, HTML) still counts at its serialized width. CellFolder is deliberately a small
registry alongside the parser, renderer, and postprocessor registries: dialects can teach table
layout about a new hidden token without adding conditionals to the table renderer.
- myform.Tables.render_table_cell(node: mdformat.renderer.RenderTreeNode, context: mdformat.renderer.RenderContext) str#
Render and pipe-escape one cell, preserving mdformat-tables’ serialization contract.
- myform.Tables.postprocess_table_escapes(text: str, _: mdformat.renderer.RenderTreeNode, __: mdformat.renderer.RenderContext) str#
Escape delimiter-shaped paragraph lines, preserving mdformat-tables’ fixed-point guard.
- class myform.Tables.CellFolder#
Registry that hides typically-hidden inline syntax from a table cell’s measured width.
- static register(fn: Folder, name: str = '') Folder#
Register one token folder, inferring its token name from
fold_<name>when omitted.
- classmethod fold(node: mdformat.renderer.RenderTreeNode, context: mdformat.renderer.RenderContext) str#
Return the cell’s measured text, keeping rendered markup and unknown tokens as-is.
- classmethod children(node: mdformat.renderer.RenderTreeNode, context: mdformat.renderer.RenderContext) str#
Fold and concatenate a node’s children.
- classmethod width(node: mdformat.renderer.RenderTreeNode, context: mdformat.renderer.RenderContext) int#
Return the terminal-cell width of a folded node, treating unprintable spans as empty.
- myform.Tables.fold_inline(node: mdformat.renderer.RenderTreeNode, context: mdformat.renderer.RenderContext) str#
Fold an ordinary inline container through its children.
- myform.Tables.fold_td(node: mdformat.renderer.RenderTreeNode, context: mdformat.renderer.RenderContext) str#
Fold one table data cell through its inline child.
- myform.Tables.fold_th(node: mdformat.renderer.RenderTreeNode, context: mdformat.renderer.RenderContext) str#
Fold one table header cell through its inline child.
- myform.Tables.fold_text(node: mdformat.renderer.RenderTreeNode, _: mdformat.renderer.RenderContext) str#
Use decoded text rather than the Markdown escapes required to serialize it.
- myform.Tables.fold_link(node: mdformat.renderer.RenderTreeNode, context: mdformat.renderer.RenderContext) str#
Hide link syntax and destinations, retaining the rendered link label.
- myform.Tables.fold_image(node: mdformat.renderer.RenderTreeNode, context: mdformat.renderer.RenderContext) str#
Hide image syntax and URLs, retaining its visible alt label as the textual fallback.
- myform.Tables.fold_myst_role(node: mdformat.renderer.RenderTreeNode, context: mdformat.renderer.RenderContext) str#
Hide a MyST role’s wrapper and explicit
label <target>reference target.