Expand description
Shared 2D geometry pass for grid tables.
A grid table’s logical cells are rectangles over a canonical column/row
grid, and a spanning cell’s content is non-contiguous in the byte stream
(a rowspan cell’s text is interleaved with other cells’ bytes and separator
lines). A rowan CST node covers a single contiguous range, so the cell
tiling cannot be represented as CST nodes and must be recovered by a 2D pass
downstream of the parser. This module is the single home for that pass,
consumed by both the pandoc-native projector (pandoc_ast::grid_table) and
the formatter’s spanning-grid engine, so the geometry is computed one way.
The algorithm mirrors pandoc’s gridtables: build a padded char grid,
take the canonical column boundaries as the union of + positions across
every “sep-style” line and the canonical row boundaries as those lines’
indices, then detect each cell as the smallest valid bounding rectangle.
Positions are character indices (matching pandoc, which lays grid tables
out on the source character grid), not display columns.
Structs§
- Grid
Cell Rect - One laid-out cell of a grid table over the canonical (row band × fine
column) grid.
contentis the cell’s interior text with one leading pad space stripped per line, trailing whitespace trimmed, and leading/trailing blank lines dropped, joined with\n. - Grid
Layout - Canonical geometry of a grid table plus its detected cells.
Functions§
- analyze_
grid - Analyze a grid table’s lines into its canonical geometry and cell tiling.