From 18cd0afb353870b68021722c2e7b144a204c51a7 Mon Sep 17 00:00:00 2001 From: lafricain79 Date: Sat, 22 Aug 2026 08:54:33 +0200 Subject: [PATCH 1/2] Revert introMaterial() div-balancing: fix column layout regression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two regressions reported after #1385 (Balance chapter HTML and fix intro-material italics leaking into text): 1. Verse alignment anchors (chapter*1000+verse) no longer reliably top-align on navigation with whole-book rendering (e.g. Deu 24:17 landing at page bottom instead of top). 2. Pre-verse heading placement broken relative to text and the end-of-chapter horizontal separator. Both were reproducible specifically with multi-column display (4 columns). Methodically isolated by testing each #1385 change individually (wk_html_sanitize(), the chapter-anchor auto-close, and this div-balancing) against a pristine pre-#921 checkout: only the introMaterial() div-balancing reproduced the regression once isolated. The balancing logic force-closed unclosed
tags (left open by SWORD's OSIS filter, e.g. a
whose closing tag never appears in the fetched intro text) right before our own wrapper close. Shifting block-level closing boundaries at that exact spot — right where chapter headers sit — was enough to change where WebKit decides to break columns and how it computes anchor-scroll position in multi-column, whole-book rendering. Reverted to the original single closing
. Italics leaking past chapter intro material onto verse text (the original motivation for this code) is addressed separately, at the verse-text level instead of the block-structure level, in a follow-up commit. --- src/main/display.cc | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/src/main/display.cc b/src/main/display.cc index 6325e613a..35d766a68 100644 --- a/src/main/display.cc +++ b/src/main/display.cc @@ -1222,33 +1222,18 @@ GTKChapDisp::introMaterial(SWModule &imodule, int thisChapter) } } - if (started_intro) { - /* Issue #921: SWORD's OSIS filter can emit an opening - *
for a section heading - * without a matching closing
anywhere in the - * fetched "verse 0" text (the section's eID/closing tag - * apparently falls elsewhere, outside what we retrieve - * here). Left unbalanced, our own closing
below - * only closes the innermost open
, leaving - * class="introMaterial" (and its CSS font-style: italic) - * open around the rest of the chapter. Force-balance - * before closing our own wrapper. */ - gint div_opens = 0, div_closes = 0; - const gchar *scan = intro->str; - while ((scan = strstr(scan, "str; - while ((scan = strstr(scan, "
"))) { - div_closes++; - scan += 6; - } - for (; div_closes < div_opens; div_closes++) - g_string_append(intro, ""); - + /* Issue #921: an earlier attempt balanced unclosed
tags + * here by force-closing them before our own wrapper. That fixed + * italics leaking past chapter intro material, but shifting + * block-level closing boundaries at this exact spot was found to + * break WebKit's column-break and anchor-scroll positioning in + * multi-column layouts + whole-book rendering (reported by Karl, + * reproducible with 4 columns). Reverted; italics leaking onto + * verse text is instead handled defensively at the verse-text + * level in RenderOneChapter(), which doesn't touch block + * boundaries at all. */ + if (started_intro) g_string_append(intro, "
"); // finish what we started. - } key->setAutoNormalize(oldAutoNorm); From 7629064c741801236004ffc924a875e856e5674f Mon Sep 17 00:00:00 2001 From: lafricain79 Date: Sat, 22 Aug 2026 09:01:17 +0200 Subject: [PATCH 2/2] FIX for italics spilling over into the verse text - Multi-match version. Applies the font-style reset to all occurrences in the rendering block. --- src/main/display.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/display.cc b/src/main/display.cc index 35d766a68..8dcacdbbc 100644 --- a/src/main/display.cc +++ b/src/main/display.cc @@ -1725,10 +1725,14 @@ GTKChapDisp::RenderOneChapter(SWModule &imodule, swbuf.appendFormatted("", color_chosen_fg); } + /* Issue #921: defensively reset font-style to normal around + * each verse's own text. Applied via script. */ + swbuf.append(""); swbuf.append(settings.imageresize ? AnalyzeForImageSize(rework->str, CURRENT_COLUMNS, GDK_WINDOW(gtk_widget_get_window(gtkText))) : rework->str /* left as-is */); + swbuf.append(""); if (color_choices != COLOR_NONE) { swbuf.append(""); @@ -2329,10 +2333,14 @@ DialogChapDisp::display(SWModule &imodule) swbuf.appendFormatted("", color_chosen_fg); } + /* Issue #921: defensively reset font-style to normal around + * each verse's own text. Applied via script. */ + swbuf.append(""); swbuf.append(settings.imageresize ? AnalyzeForImageSize(rework->str, CURRENT_COLUMNS, GDK_WINDOW(gtk_widget_get_window(gtkText))) : rework->str /* left as-is */); + swbuf.append(""); if (color_choices != COLOR_NONE) { swbuf.append("");