Terminal styling and layout widgets for OCaml (tables, trees, panels, colors)
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-tty: skip empty header row in table rendering

When all column headers are empty strings, the table now omits the
header row and separator instead of rendering a blank row.

+9 -7
+9 -7
lib/table.ml
··· 267 267 render_horizontal ppf t widths chars.top_left chars.top_cross 268 268 chars.top_right chars.top; 269 269 270 - (* Header row *) 270 + (* Header row (skip if all headers are empty) *) 271 271 let headers = List.map (fun col -> col.header) t.columns in 272 - render_row ppf t widths t.header_style headers; 273 - 274 - (* Separator after header *) 275 - if List.length t.rows > 0 then 276 - render_horizontal ppf t widths chars.left_cross chars.cross 277 - chars.right_cross chars.top; 272 + let has_headers = 273 + List.exists (fun h -> Span.to_plain_string h <> "") headers 274 + in 275 + if has_headers then ( 276 + render_row ppf t widths t.header_style headers; 277 + if List.length t.rows > 0 then 278 + render_horizontal ppf t widths chars.left_cross chars.cross 279 + chars.right_cross chars.top); 278 280 279 281 (* Data rows *) 280 282 List.iter (fun row -> render_row ppf t widths Style.none row) t.rows;