Skip to content

qmd writer drops empty header row from pipe tables and promotes the first body row to a header #175

@rundel

Description

@rundel

A pipe table whose header row is empty (every header cell blank) is parsed as a Table with TableHead [] [] (zero header rows). The writer omits the empty header line entirely, emitting the alignment delimiter directly above what was the first body row. The re-parser then reads that body row as the table header, so head$rows flips from length 0 to length 1 and the body loses one row.

$ printf -- '|     |     |\n|-----|-----|\n| a   | b   |\n| c   | d   |\n'
|     |     |
|-----|-----|
| a   | b   |
| c   | d   |

$ printf -- '|     |     |\n|-----|-----|\n| a   | b   |\n| c   | d   |\n' | cargo run --bin pampa --
[ Table ( "" , [] , [] ) (Caption Nothing []) [(AlignDefault, ColWidthDefault), (AlignDefault, ColWidthDefault)] (TableHead ( "" , [] , [] ) []) [TableBody ( "" , [] , [] ) (RowHeadColumns 0) [] [Row ( "" , [] , [] ) [Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "a"]] , Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "b"]] ] , Row ( "" , [] , [] ) [Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "c"]] , Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "d"]] ] ]] (TableFoot ( "" , [] , [] ) [] ) ]

$ printf -- '|     |     |\n|-----|-----|\n| a   | b   |\n| c   | d   |\n' | cargo run --bin pampa -- -t qmd
| a   | b   |
| --- | --- |
| c   | d   |

$ printf -- '|     |     |\n|-----|-----|\n| a   | b   |\n| c   | d   |\n' | cargo run --bin pampa -- -t qmd | cargo run --bin pampa --
[ Table ( "" , [] , [] ) (Caption Nothing []) [(AlignDefault, ColWidthDefault), (AlignDefault, ColWidthDefault)] (TableHead ( "" , [] , [] ) [Row ( "" , [] , [] ) [Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "a"]] , Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "b"]] ] ]) [TableBody ( "" , [] , [] ) (RowHeadColumns 0) [] [Row ( "" , [] , [] ) [Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "c"]] , Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "d"]] ] ]] (TableFoot ( "" , [] , [] ) [] ) ]

Examples from quarto-web:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions