From 0f17eb3cd9c618e54bbbdb9ba873fc1d18168b0e Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Sun, 12 Apr 2026 10:05:22 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20IPA:Aus=20=E2=80=94=20strip=20all=20brack?= =?UTF-8?q?ets=20before=20skipping=20IPA=20block?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When ipa_mode=none, the entire IPA processing block was skipped, including the bracket-stripping logic. Now strips ALL square brackets from content columns BEFORE the skip, so IPA:Aus actually removes all IPA from the display. Co-Authored-By: Claude Opus 4.6 (1M context) --- klausur-service/backend/grid_editor_api.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/klausur-service/backend/grid_editor_api.py b/klausur-service/backend/grid_editor_api.py index 6748d68..cd53087 100644 --- a/klausur-service/backend/grid_editor_api.py +++ b/klausur-service/backend/grid_editor_api.py @@ -961,6 +961,21 @@ async def _build_grid_core( ipa_target_cols: set = set() all_content_cols: set = set() skip_ipa = (ipa_mode == "none") + + # When ipa_mode=none, strip ALL square brackets from ALL content columns + if skip_ipa: + _SQUARE_BRACKET_RE_NONE = re.compile(r'\s*\[[^\]]+\]') + for cell in all_cells: + ct = cell.get("col_type", "") + if not ct.startswith("column_"): + continue + text = cell.get("text", "") + if "[" in text: + stripped = _SQUARE_BRACKET_RE_NONE.sub("", text) + if stripped != text: + cell["text"] = stripped.strip() + cell["_ipa_corrected"] = True + if not skip_ipa and total_cols >= 3: # Detect English headword column via IPA signals (brackets or garbled). col_ipa_count: Dict[str, int] = {}