Balance chapter HTML and fix intro-material italics leaking into text - #1385
Conversation
Follow-up to crosswire#921: while chapter intro material (book/section headings) is meant to render in italics via ".introMaterial { font- style: italic; }", two related bugs let that styling — and malformed markup in general — leak into the rest of the chapter on modules with rich introductions (e.g. FreCrampon). - GTKChapDisp::introMaterial() (src/main/display.cc): SWORD's OSIS filter can emit an opening <div type="subSection" ...> for a section heading with no matching closing </div> anywhere in the fetched text. Now counts <div>/</div> occurrences and appends any missing closing tags before closing our own wrapper, so the block is always self-balanced regardless of what the filter provides. - wk_html_sanitize() (src/webkit/wk-html.c): parses the final assembled HTML with libxml2 (HTML_PARSE_RECOVER) and re-serializes it before handing it to WebKit, rather than letting WebKit's own parser silently repair mismatched tags unpredictably. General safety net for similar cases we may not have found yet. - CSS: added ".introMaterial h2.chapterHeader { font-style: normal; }" so section/chapter titles stay upright — only the narrative intro text should be italic, not its headings.
|
Let me work on it. Tomorrow or Monday. |
* Revert introMaterial() div-balancing: fix column layout regression 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 <div> tags (left open by SWORD's OSIS filter, e.g. a <div type=subSection> 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 </div>. 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. * FIX for italics spilling over into the verse text - Multi-match version. Applies the font-style reset to all occurrences in the rendering block. --------- Co-authored-by: lafricain79 <lafricain79@gmail.com>
|
Oh...dear... |
|
See the theory of Claude (I can't test because I can't reproduice the issue): Working theory: the change most likely responsible is the unconditional I wrapped around every verse's text to stop italics bleeding onto verse content (a fix that shipped in the follow-up commit, separate from the original div-balancing that caused your first report). Previously, verse text with no highlight/coloring had no wrapping inline element at all; adding one for every verse may be interfering with WebKit's last-line detection for text-align: justify. I'd like to replace it with a fix that doesn't add any new wrapping element around verse text at all -- balancing each fetched intro fragment individually, right where it's fetched, instead of stacking corrections at the end of the block. Since I can't reproduce this locally, could you tell me:
In the meantime I'll prepare a candidate branch with the more targeted fix (no verse-wrapping span, localized div-balancing) and would appreciate if you could test it on your end before I ask for a merge, rather than repeating the merge-then-regress cycle from the last two rounds. |
|
Can you try the last PR? |
|
Oh, right—I'd only noticed the ends of the paragraphs that didn't have the problem! So my fix isn't working. |
|
Karl, it seems the problem is still NET. I don't see the problem with other module. And you? |
|
I'm glad of that, because I was about to say "it's NET only after all" and was going to schedule some time this evening to trace the generated HTML to find what's wrong, much as I had to do a few weeks ago for |
|
Ok, something is wrong with the picture (chapter numbers are pictures). |
|
Let's take this from a different point of reference. The original intent of these changes was to handle a (rare?) case where text returned from Sword was not self-consistent, insofar as it did not close I find I really don't like the solution of wrapping every single verse in a font spec. That creates a great deal of extra work for WebKit and will slow down display considerably. I am wanting to find a different solution, where the text returned from Sword is immediately repaired on the spot, so that no further analysis and repair is ever necessary. One and done. And in any event, if Sword is returning improper text, a bug report should be filed against whatever part of Sword is returning unbalanced content. |
|
I worked on this with Claude yesterday. He fixed the justification issue. Although I see there’s still some random justification on the last line. I wonder if it wasn’t already there before. Why did we take on this task? Well, because of a problem that’s actually quite serious. Chapter 1 of the module books appears in italics when the chapter titles are, for example, freCrampon, ktuvb, or freVulgglaire. I think the simplest thing to do for now is probably to revert the PR. If you have a chance to look into what’s going on with FreCrampon, I’d appreciate it. |
|
If FreCrampon is not an example of the problem, in what module can one be found? |
|
I worked yesterday all day on the frecrampon, it was completely buggy. I really think that for now it's better to revert. But otherwise a module that has this italics problem is the ktuvb, chap. 1 of the books recovers the italics of the intros. |
|
Yes indeed it's not very serious for the KTUVB, it's just the first title which is in italics, it's not very serious especially since it's the name of the book. So I repeat myself rather than waste time let's reverse the PR, to start again on a clean basis but with a correct NET and frecrampon module. Unless you really see something relevant of course. |
|
Oh, "luyantiku" is italicized. I didn't even notice that until now. I was looking for italics in the text itself. Well, anyway, as you say, I'll revert and get us back to a previously-known state. |
|
As regards KtuVB, where book names (only) are italicized... I believe the problem is with the module markup. It's not happening in the XHTML generated by Xiphos. It's in how the pre-chapter content is encoded, and how Sword renders that into XHTML. It's not wrong, it's just unexpected. Exodus 0:0, pre-book: Sword renders this into XHTML: Most of this is simply I've traced carefully through the execution of I've experimented with a simple change that adds I'm open to contrary analysis and opinion. |














Follow-up to #921: while chapter intro material (book/section headings) is meant to render in italics via ".introMaterial { font- style: italic; }", two related bugs let that styling — and malformed markup in general — leak into the rest of the chapter on modules with rich introductions (e.g. FreCrampon).
GTKChapDisp::introMaterial() (src/main/display.cc): SWORD's OSIS filter can emit an opening <div type="subSection" ...> for a section heading with no matching closing anywhere in the fetched text. Now counts
wk_html_sanitize() (src/webkit/wk-html.c): parses the final assembled HTML with libxml2 (HTML_PARSE_RECOVER) and re-serializes it before handing it to WebKit, rather than letting WebKit's own parser silently repair mismatched tags unpredictably. General safety net for similar cases we may not have found yet.
CSS: added ".introMaterial h2.chapterHeader { font-style: normal; }" so section/chapter titles stay upright — only the narrative intro text should be italic, not its headings.