From f23aaaea51795004452faac4471973143a91ef65 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Sat, 11 Apr 2026 22:21:09 +0200 Subject: [PATCH] Fix false header detection: skip continuation lines and mid-column cells Single-cell rows were incorrectly detected as headings when they were actually continuation lines. Two new guards: 1. Text starting with "(" is a continuation (e.g. "(usw.)", "(TV-Serie)") 2. Single cells beyond the first two content columns are overflow lines, not headings. Real headings appear in the first columns. Co-Authored-By: Claude Opus 4.6 (1M context) --- klausur-service/backend/grid_editor_helpers.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/klausur-service/backend/grid_editor_helpers.py b/klausur-service/backend/grid_editor_helpers.py index 8100dc2..ba1ae36 100644 --- a/klausur-service/backend/grid_editor_helpers.py +++ b/klausur-service/backend/grid_editor_helpers.py @@ -1053,6 +1053,16 @@ def _detect_heading_rows_by_single_cell( text = (cell.get("text") or "").strip() if not text or text.startswith("["): continue + # Continuation lines start with "(" — e.g. "(usw.)", "(TV-Serie)" + if text.startswith("("): + continue + # Single cell NOT in the first content column is likely a + # continuation/overflow line, not a heading. Real headings + # ("Theme 1", "Unit 3: ...") appear in the first or second + # content column. + first_content_col = col_indices[0] if col_indices else 0 + if cell.get("col_index", 0) > first_content_col + 1: + continue # Skip garbled IPA without brackets (e.g. "ska:f – ska:vz") # but NOT text with real IPA symbols (e.g. "Theme [θˈiːm]") _REAL_IPA_CHARS = set("ˈˌəɪɛɒʊʌæɑɔʃʒθðŋ")