Skip to content

Android EPUB stripHtml(): blockAwareText() only separates a hardcoded tag subset, smashing words together for section/td/dt/dd/figure/etc. #639

Open

Description

@github-actions

Found during principal review of PR #632 (fixes #630).

Background

PR #632 fixes #630 by replacing doc.text() (Jsoup) with a custom blockAwareText() walk in EpubReaderViewModel.kt that inserts \n at the close of tags in a hardcoded LINE_BREAK_TAGS set: p, div, h1-6, li, tr, blockquote, hr, br.

The regression

Jsoup's own doc.text() — the function being replaced — inserts a space at the boundary of any block-level element (per Jsoup's own Tag.isBlock), not just the eight tag names in LINE_BREAK_TAGS. Verified empirically against the pinned Jsoup 1.18.1 jar (same technique PR #632 itself used):

input:  <table><tr><td>A</td><td>B</td></tr></table>
doc.text():       "A B"
blockAwareText(): "AB\n"     <- no separator at all

input:  <section>Sec1</section><section>Sec2</section>
doc.text():       "Sec1 Sec2"
blockAwareText(): "Sec1Sec2"  <- no separator at all

input:  <dl><dt>Term</dt><dd>Def</dd></dl>
doc.text():       "Term Def"
blockAwareText(): "TermDef"   <- no separator at all

input:  <p>Before</p><figure><figcaption>Cap</figcaption></figure><p>After</p>
doc.text():       "Before Cap After"
blockAwareText(): "Before\nCapAfter\n"   <- "CapAfter" smashed together

td, section, dt, dd, figure, figcaption (and other valid EPUB3 block tags — article, header, footer, nav, aside, address, ul/ol, table, pre, form, fieldset, ...) are not in LINE_BREAK_TAGS, so blockAwareText() emits no separator at all between their content and whatever follows, whereas the old doc.text() at least emitted a space.

EpubTextPreprocessor.normalizeWhitespace() (the last step of .clean()) only collapses existing whitespace runs and excess blank lines — it does not insert a missing word boundary, so this reaches the TTS engine as one run-on word (e.g. "CapAfter").

Impact

Any real-world EPUB using <section> (very common in EPUB3, which encourages sectioning content), a <table>, a <dl> (glossaries/footnotes), or <figure>/<figcaption> will have words from adjacent block elements silently concatenated with no space when read aloud via TTS — worse than before PR #632 for those specific tags, since doc.text() at least separated them with a space (just not a newline).

Suggested fix

blockAwareText()'s tail() handler should fall back to appending a space (matching Jsoup's own block-boundary behavior) for any block-level element not in LINE_BREAK_TAGS, rather than emitting nothing. Jsoup's Element.tag().isBlock() is the same predicate doc.text() itself already relies on internally, so checking it directly (rather than hand-maintaining a tag-name allowlist) would prevent this class of gap from recurring for other tags.

Verification

Reproduced with a standalone Java program against org.jsoup:jsoup:1.18.1 (the version pinned in gradle/libs.versions.toml), porting blockAwareText()'s exact logic and comparing its output to doc.text() on the inputs above.

Activity

  1. libravault-xyz commented on Aug 26, 2026

    @libravault-xyz
    Collaborator

    Automated pipeline health check: This issue (filed by github-actions[bot], CONTRIBUTOR association) has received zero dev-agent.yml runs and zero explanatory comment of any kind since it was filed.

    Same author-association trust-gate-skip signature already tracked on #469/#475/#479/#388/#408/#433/#437/#441/#544/#558/#582 — but unlike that earlier batch, this issue never got even the explain-trust-gate-skip job's own skip-reason comment, consistent with the regression confirmed on #437/#441 (that job's gh issue comment step has no actions/checkout/--repo, so it fails before posting: fatal: not a git repository).

    Not self-healing: no status label to toggle, and .github/workflows/dev-agent.yml is a sensitive path this routine won't edit.

    This now makes at least 13 open issues sitting with zero pipeline engagement: #469, #475, #479, #487, #504, #523, #534, #556, #557, #559, #561, #581, #589, #611, #626, #639. A tracked issue for the underlying explain-trust-gate-skip checkout/--repo bug has been recommended across at least two prior automated runs (2026-08-23 on #469, 2026-08-24 on #437/#441) but doesn't appear to have been filed yet.

    Action needed: someone with write access can workflow_dispatch triage this issue manually, and/or fix explain-trust-gate-skip's gh issue comment step (add actions/checkout or --repo ${{ github.repository }}) so future instances self-report instead of going silent.


    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions