fix: don't merge column header rows as continuations

Rows with 3+ short-valued cells (avg ≤10 chars) and an empty first cell
are column headers (e.g. "UR | SC | ST | OBC | EWS"), not text overflow
from the previous row. Prevents them from being merged into the
preceding section title row.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Abimael Martell
2026-04-04 02:24:52 -07:00
co-authored by Claude Opus 4.6
parent 1dcb0c6feb
commit 0300e96b7d
2 changed files with 7 additions and 1 deletions
+4
View File
@@ -112,10 +112,14 @@ fn clean_table_cells(cells: &[Vec<String>]) -> (Vec<Vec<String>>, Vec<String>) {
// header like "Category No. 03 - ...") — these are spanning headers,
// not overflow from the previous row.
let has_long_spanning_cell = non_first_cells.len() == 1 && non_first_cells[0].len() > 15;
// Rows filling most columns with short values are header or data rows,
// not text overflow (e.g. "UR | SC | ST | OBC | EWS" column headers).
let looks_like_header_row = non_first_cells.len() >= 3 && avg_cell_len <= 10.0;
let is_classic_continuation = first_cell.is_empty()
&& !non_first_cells.is_empty()
&& !is_short_subheader
&& !looks_like_data_row
&& !looks_like_header_row
&& !has_long_spanning_cell
&& cleaned.len() > 1;
+3 -1
View File
@@ -46,7 +46,9 @@ l
|Temp|Pressure||Volume|||Density||Enthalpy|||Entropy|Temp|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|°C|[kPa]|[m3 Liquid v f|/kg]|Vapour v g|Liquid d f|[kg/m3] Vapour d g|Liquid H f|[kJ/kg] Latent H fg|Vapour H g|Liquid S f|[kJ/K-kg] Vapour S g|°C|
|°C|[kPa]|[m3|/kg]|||[kg/m3]||[kJ/kg]|||[kJ/K-kg]|°C|
|||Liquid||Vapour|Liquid|Vapour|Liquid|Latent|Vapour|Liquid|Vapour||
|||v f||v g|d f|d g|H f|H fg|H g|S f|S g||
|-100|1.2|0.0006|10.0000|1679.0|0.100|113.3|192.8|306.1|0.6077|1.7210|-100|
|---|---|---|---|---|---|---|---|---|---|---|---|