Skip to content

Tables: Track rowspan coverage for column count validation #314

@nlopes

Description

@nlopes

Problem

When a table has cols= specified, the parser validates that each row has the correct number of columns. However, with rowspan cells, subsequent rows should have fewer visible cells because some column positions are "occupied" by the spanning cell from a previous row.

Currently, rows under a rowspan trigger a warning about incorrect column count when they correctly have fewer visible cells.

Example

[cols="3*"]
|===
| A | B | C

.2+| Spans rows | D | E
| F | G
| H | I | J
|===

Row 3 (| F | G) correctly has only 2 visible cells because column 1 is occupied by the rowspan from row 2. But with strict cols=3 validation, this would warn.

Solution

Track "occupied" column positions using a Vec<usize> where each entry represents rows remaining for that column's rowspan. When processing a row:

  1. Decrement all non-zero entries
  2. When placing a cell, skip occupied positions
  3. Validate: visible cells + occupied positions + (colspan-1 for each cell) = ncols

Priority

Medium - current implementation works for most cases, this is an edge case with strict column count validation.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions