Skip to content

Balance chapter HTML and fix intro-material italics leaking into text - #1385

Merged
karlkleinpaste merged 1 commit into
crosswire:masterfrom
LAfricain:HtmlSanitize2
Aug 21, 2026
Merged

Balance chapter HTML and fix intro-material italics leaking into text#1385
karlkleinpaste merged 1 commit into
crosswire:masterfrom
LAfricain:HtmlSanitize2

Conversation

@LAfricain

Copy link
Copy Markdown
Contributor

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

    /
    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.

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.
@karlkleinpaste
karlkleinpaste merged commit a358917 into crosswire:master Aug 21, 2026
7 checks passed
@karlkleinpaste

Copy link
Copy Markdown
Contributor

I had thought this change was benign so I merged it easily.

But now, having used it some more, I'm finding 2 serious problems.

  • The code generates verse alignment anchors ("chapter * 1000 + verse"), and on navigation, sets top alignment to the current verse's anchor. With this latest update, anchors are not reliably top-aligned. (Sometimes they are. More often they are not.) With whole book rendering enabled, navigate to a sample spot in a large book; here, I used Deu 24:17. This top alignment does not occur at that point -- in my example, it "aligns" to page bottom. This is not specific to any module: NASB and ESV also go to page bottom.

  • The placement of pre-verse headings is broken with respect to the text and to the end-of-chapter horizontal separator. See right column.

With change:
Screenshot at 2026-08-21 10-38-23

ESV, showing mis-aligned horizontal separator and excess whitespace following the next pre-verse heading:
Screenshot at 2026-08-21 10-52-39

With change reverted in a local branch, showing normal whitespace after pre-verse heading, and proper placement of horizontal separator:
Screenshot at 2026-08-21 10-41-04

Either I will revert this or an update is needed to restore correct anchor alignment and header + separator placement.

@LAfricain

LAfricain commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

Let me work on it. Tomorrow or Monday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants