Skip to main content

Module tablepass

Module tablepass 

Source
Expand description

AST pass that wraps every GFM table in a horizontal-scroll container.

Runs after the math/mermaid passes and before format_ast. Each NodeValue::Table gets a <div class="docgen-table-scroll"> opening block inserted immediately before it and a matching </div> immediately after, so a table wider than the reading column scrolls inside its own region instead of squishing its columns (or forcing whole-page horizontal overflow). The CSS side switches tables to table-layout: auto with per-cell min/max widths, so columns size to their content — the wrapper is what makes the overflow scrollable rather than clipped.

Raw HTML is allowed through because comrak_options().render.unsafe = true (same mechanism mermaidpass relies on). Wrapping uses sibling insertion rather than node replacement because a table must keep rendering as a real <table> — only its surroundings change.

Functions§

transform_tables
Wrap every table node in a .docgen-table-scroll div. Returns the number of tables wrapped (0 when the document has none).