fix(koreader): resolve element XPath progress against visible body text#261
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f1dd3a948
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } else if (nonVisibleDepth > 0) { | ||
| // Ignore head/style/script/title text. KOReader XPaths are body-relative, and CSS text | ||
| // should not contribute to intra-spine progress. |
There was a problem hiding this comment.
Stop parsing script text as markup
When a script or style block contains a literal < (for example if (a < b)), this ignore branch is never reached because < is handled earlier as a tag opener. The later real </script>/</style> can then be swallowed as attributes of that bogus tag, leaving nonVisibleDepth nonzero and causing all following body text to be skipped, so KOReader progress mapping falls back or resolves near the start for EPUBs with inline scripts/styles. While inside these non-visible raw-text elements, bytes need to be ignored until the actual closing tag rather than fed through the normal tag parser.
Useful? React with 👍 / 👎.
* fix: improve minimal theme's cover thumbnails (crop image before dithering) * fix: adapt minimal cover thumbnails for unusual ratios * fix: use pinned input manager held-time API * fix: improve lyra carousel thumbnails * feat: add additional long-press options in recent books view * fix: move reader footnotes menu item above chapter selector #170 * fix: change label to "Download Font Size Range" * fix(fonts): combine downloaded font ranges by family * docs: update changelog * fix: use stable EPUB cache path when moving finished books * feat(settings): change "Page as Sleep Screen" feature to "Quick Resume" * fix: address cppcheck diagnostics * fix(epub): bump section cache for layout changes * docs: update changelog * ci: clean up github workflows * fix: add translations for STR_QUICK_RESUME * chore(i18n): refine quick resume translations * chore(i18n): refine quick resume translations * fix: show wifi connected status from settings * fix: constrain status bar settings in landscape * feat: auto inject build info into sleep screen for debug enviroment * fix(settings): preserve quick resume timeout preference * chore: fix the Italian translation (crosspoint-reader#2095) * refactor: unify book cache clearing for epub, txt, and xtc files (crosspoint-reader#1875) fix(settings): mirror quick resume timeout behavior on web settings fix(settings): compare quick resume sleep screen by enum * fix: wrap book title in long-press menu * feat(opds): allow cancelling book downloads * fix: validate saved credential payloads (#177) * feat: add OPDS cancellation and better retry visual feedback (#178) * fix: show loading state before opds retry * feat: add more debugging wifi connection diagnostics * fix: make opds download cancellation more responsive * docs: update changelog * docs: update changelog for next release * docs: update readme * fix: lyra carousel popups missing * correctly draw status bar preview while editing in non portrait orientation With CW, CCW, Inverted orientations When in Reader If you open Book menu > Reader Options > Customize Status Bar The preview is drawn in the incorrect location due to a hardcoded offset, this commit sets this to change based on orientation * feat(reader): add adjustable line height setting * style: run clang-format * fix: improve font download timeout diagnostics * ci: run firmware build on self-hosted runner * fix: improve OPDS and font download speeds and reliability (#195) * fix(opds): show more specific opds errors for low memory scenario * fix(opds): free sd font before catalog loading * fix: improve font download timeout diagnostics * fix(opds): show more specific opds errors for low memory scenario * fix(opds): free sd font before catalog loading * fix: increase opds transfer buffer back up to 4096 and increase font buffer to 2048kb * ci: build only tiny firmware in CI * feat(stats): sync and aggregate global reading stats between devices * feat: save auto page turn interval per book (#192) * fix: harden epub progress saves during sync (#193) * fix: harden epub progress saves during sync * fix: clamp KOReader remote progress page counts * correctly draw status bar preview while editing in non portrait orientation With CW, CCW, Inverted orientations When in Reader If you open Book menu > Reader Options > Customize Status Bar The preview is drawn in the incorrect location due to a hardcoded offset, this commit sets this to change based on orientation * fix: store only peer stats in synced stats folder * docs: update documentation for synced reading stats * docs: update readme * feat(reader): anchor epub bookmarks to paragraphs * feat(reader): split synced reading stats totals * feat: show bookmark text snippets * feat: add tilt-to-turn direction setting * docs: update readme * fix: translate tilt direction label * fix: preserve epub sections when css cache rebuild fails * fix: show loading popup before reader startup work * fix: preserve partial epub css cache on low memory * fix: clean up cppcheck warnings * fix: preserve epub section caches after partial css rebuilds * fix(epub): release table fallback memory before layout abort * fix(epub): reduce sd font memory pressure during indexing * fix(epub): fallback to built-in font on sd font layout OOM * fix: keep inverted button hint outlines upright * docs: update docs * feat: add OPDS download filename format setting * fix(epub): harden pagination page allocation * fix(epub): clarify low-memory image warning * fix: preserve book progress during web uploads * feat: add time left in chapter/book * feat: move reader clock to top status bar * fix: clean up cppcheck style warnings * chore: bump version * docs: clean up unreleased changelog * chore: merge upstream crosspoint * feat: add Next/Next side button layout * feat: add preview for top bar when customizing status bar * fix: revert book cache bump * fix: restore tiled grascale render path * Revert "feat: tiled grayscale rendering to drop the storeBwBuffer peak (crosspoint-reader#2106)" This reverts commit 4ee4068. * fix: hide missing word-joiner glyphs in epub text * feat: consolidate settings menu items * fix: improve EPUB book time-left estimates * fix: stabilize displayed wifi mac address * fix: update clock padding * fix: adjust finished-book prompt timing * fix: SD font pre-indexing guard * feat: add ability to display publisher page numbers when present * fix: align reader clock padding * docs: match cache versions with code * fix: make publisher page marker scratch buffers const * fix: expose disabled side button layout * chore: remove feature requests from issue types * fix: EPUB skip-depth handling for image alt fallback * refactor: finalize EPUB publisher page markers once * feat: add RTL support in epub and txt readers (crosspoint-reader#1700) Co-authored-by: Zach Nelson <zach@zdnelson.com> * fix: add missing swedish translation for disabled * fix: complete Spanish, Catalan and Valencian strings (crosspoint-reader#2203) Co-authored-by: Leopoldo Pla Sempere <leopoldo.pla@treelogic.com> * fix(home): harden Lyra Carousel under low heap * fix: make clock UTC offset picker easier to use * fix: compute max width of minutes based on all allowable values * fix: correct Vietnamese i18n string offsets * fix: add missing settings menu translations * fix: inaccurate KOReader sync when syncing at chapter start * fix: automatically attempt to sync clock * fix: stop counting backward page turns in reading stats * fix: only count page turns after 2 seconds * feat: display date for x3 * fix: recover bookmarks from legacy epub hash filenames * chore: bump version * fix: add more explicit KOReader sync error messaging * fix: improve book time-left estimates after quick navigations * fix: remove 'Go to Home' from in-reader menu * fix: make clock and battery top padding consistent * fix: remove duplicate nearby stats sync label * fix: lyra and lyra extended home menu icon alignment * feat: allow selecting a custom sleep folder (#227) * feat: allow selecting a custom sleep folder * feat: reapply tiled grayscale row-band rendering on X3 Re-applies the X3 row-band grayscale work that was temporarily reverted in 06ef4ca, now that open-x4-sdk is on 26648d6 (which includes the #13 row-band plane streaming the path depends on). Restores the strip render pipeline end to end: - GfxRenderer strip target (beginStripTarget/endStripTarget, getWriteTarget/ getWriteOriginY/getWriteRows), real glyphIntersectsStrip, and writeGrayscalePlaneStrip/supportsStripGrayscale - HalDisplay passthrough to EInkDisplay - DirectPixelWriter band-clipping writePixel - EpubReaderActivity tiled grayscale pass, gated on supportsStripGrayscale with a BW-snapshot fallback when unsupported or under memory pressure Also drops the temporary glyphIntersectsStrip stub that kept call sites compiling while the feature was reverted. Builds for the simulator. Needs on-device X3 verification that the current SDK AA path is fast enough and that grayscale image pages render without banding. * feat: skip loading popup for cached EPUB opens * feat: add more reading stats for X3 and add minimal stats sleep screen * fix: correct minimal stats streak wording * feat: add global stats backup * fix: add explicit error when syncing with older version of crossink * feat: update web interface and improve development workflow * feat: add dark reader mode * docs: minor formatting update to readme * fix: localize minimal stats streak label * fix: reposition stats and swap 'new reader' icon * fix: alignment and spacing fixes * fix: adjust reading stats padding again * feat: improve rendering of controls menu * feat: improve rendering of display menu * feat: improve rendering of reader menu * fix: reduce emoji coverage to more popular ones to reduce firmware size * feat: add hebrew support to UI fonts * fix: invert tilt-page-turn confirmation pop up in dark mode * fix: gate minimal stats to x3 devices only * fix: align book time-left with displayed progress * feat: show reader font sizes as point sizes * fix: tighten reading pace sample cutoff * fix: filter out reading pace samples greater than twice the average * fix: german translation for STR_INVERTED (crosspoint-reader#2269) * fix(epub): decode percent-encoded internal asset paths so assets render correctly (crosspoint-reader#2249) * **What is the goal of this PR?** * Fix EPUBs where internal file references are written in URL-style escaped form, like spaces appearing as `%20`, so the reader can find the right files instead of treating those references as missing. * **What changes are included?** * Added a small shared helper that converts those escaped EPUB-internal paths back into their normal filenames before we try to look them up. * Applied that cleanup step across the EPUB parsing flow wherever we resolve internal references, including cover images, manifest items, TOC links, spine entries, and inline HTML images. * Kept the change narrowly focused on EPUB-internal asset resolution rather than changing broader URL or networking behavior. * The user-facing bug here is that some books package their internal filenames in an escaped form, so a file like `Chapter 1.xhtml` may be referenced more like `Chapter%201.xhtml`. The reader was treating that escaped text as the literal filename, which means otherwise-valid books could lose images, covers, or chapter targets because the lookup no longer matched the real file inside the EPUB. * Risk is intentionally low. The helper only rewrites valid `%XX` escape sequences and leaves malformed input alone, so it should improve compatibility with escaped filenames without broadening the parser’s behavior in unrelated cases. * This was tested on my device with the user-provided optimized epub that was not rendering images within the text prior to this fix (cover image and chapter headers were rendering fine): [orv_main_baseline.epub.zip](https://github.com/user-attachments/files/28529545/orv_main_baseline.epub.zip) * This was also tested by the user with a local build and the affected epub and confirmed to be working * Try to open the affected epub (linked above) or any epub that has similar percent-encoding on a build prior to this fix. * Apply this fix, clear book cache, and re-open the affected book. * Images should render properly. --- While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**< YES >**_ * fix(epub): decode footnote href path before spine lookup (crosspoint-reader#2271) * docs: changelog cleanups * fix: clarify global reading stats backup label * feat: add dark mode shortcut actions * fix: prefer pace for epub book time-left * docs: readme cleanup * fix: free font catalog before SD font downloads; fixes #236 * fix: honor inverted side-button navigation in reader menus; fixes #235 * feat: improve calculations for reading time left * feat: reorganize reading stats backup settings feat: add all-time stats reset action * feat: add new menu and settings for reading stats including idle time threshold and reset all-time stats * fix: add missing translations for minimal stats sleep screen reader type and reading streak * fix: release SD fonts before wifi activities and release wifi memory on cancelled selection * fix: clean up preserved cache return condition * fix: invert quick resume markers in dark mode * fix: sync quick resume timeout from sleep screen picker * fix: replace crosspoint versions with crossink's * fix: update German translations Co-authored-by: Robert Janus<hallo@robertjanus.de> * fix: translate minimal home button labels * fix: use versioned s3 font downloads * fix: preserve heading alignment after inline images * fix: update spanish translations Co-authored-by: PlatinumPOST <PlatinumPOST@users.noreply.github.com> * fix: update translations for nearby stats sync * docs: update agents.md * fix: add missing translations for 'quick return from footnotes' * fix: show quick return from footnotes setting in web controls * docs: update readme * feat: Slovak translation add (crosspoint-reader#2251) Co-authored-by: Uri Tauber <uritaube@gmail.com> * fix: invert clock settings * fix: stop book settings back button from skipping submenus * feat: long-press menu from home screen to swap between most recently open book (single cover themes) * feat(i18n): add Vietnamese translation (crosspoint-reader#2279) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(fonts): add Vietnamese glyph coverage to the built-in UI font (crosspoint-reader#2280) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix: Compile Error: Duplicate _order values found (crosspoint-reader#2323) * fix: preview png files from file browser #251 * refactor: Drop redundant self-class prefix on applyDirectionToEntry (crosspoint-reader#2325) ## Summary Non-functional cleanup: `ChapterHtmlSlimParser::` prefix is redundant when calling `applyDirectionToEntry` within `ChapterHtmlSlimParser` methods. --- ### AI Usage Did you use AI tools to help write this code? _**NO**_ * fix: Hanging indent causes overlapping words (crosspoint-reader#2324) * feat: add the Libre Baskerville font family (crosspoint-reader#2088) ## Summary This PR adds the [Libre Baskerville ](https://github.com/impallari/Libre-Baskerville) font family to the fonts available for download in CrossPoint. ## Additional Context Baskerville is a classic font family, widely available in some form or the other in most ereaders and widely used in publishing and in the academy. Libre Baskerville is a libre (SIL Open Font License v1) implementation of it, which makes it possible for CrossPoint to ship it without issues.  --- ### AI Usage Did you use AI tools to help write this code? _**NO**_ * fix: generate sleep covers on demand #252 * feat: add custom device name; feat: hide OS metadata in file browser * feat: add additional shortcut options #222 * fix: close hal files under storage lock * fix: refresh carousel cache for dynamic home icons * fix: png page overlays causing long re-indexing #255 * fix: use Noto Sans as punctuation fallback when generating downloadable SD fonts (crosspoint-reader#2331) * fix: Restore first-line paragraph indentation (crosspoint-reader#2320) * feat: add noto sans regular * chore: merge upstream crosspoint * fix: preserve reading stats when clearing cache #253 * fix: clean up KOReader sync failure return #257 * fix: update font download sources * chore: bump version * feat: lower long-press threshold to 200ms * fix: guard file browser loads under low memory * docs: update docs to reference optimizations * fix: move boot order back * fix: use current screen for page overlay sleep background #260 * fix: add confirmation screen before clearing bookmark list * docs: update controls documentation * fix: resolve downloadable sd font sources * fix: prevent grayscale pass for page overlay images * fix: namespace CrossInk settings file * fix(koreader): resolve element XPath progress against visible body text (#261) * fix: handle KOReader element XPath offsets closes crosspoint-reader#2307 * fix(koreader): ignore non-body text when resolving xpath progress * fix: tighten KOReader anchor id parsing * feat: add setting to hide file extension #248 * feat: add file browser display row setting * fix: date overlapping the clock in roundedraff * fix: show remove read books setting in files cache * Update release catalog for v1.3.2 * fix: migrate epub state when moving finished books * fix: minor typos * fix: address release review regressions --------- Co-authored-by: Matteo Scopel <matteo@scopel.email> Co-authored-by: WuTofu <5987870+WuTofu@users.noreply.github.com> Co-authored-by: Dudekahedron <49531350+StanleyDudek@users.noreply.github.com> Co-authored-by: Zach Nelson <zach@zdnelson.com> Co-authored-by: Leopoldo Pla Sempere <leopoldo.pla@treelogic.com> Co-authored-by: Uri Tauber <uritaube@gmail.com> Co-authored-by: PlatinumPOST <PlatinumPOST@users.noreply.github.com> Co-authored-by: Martin <35097765+neresus@users.noreply.github.com> Co-authored-by: Hoang Manh Linh <jetaudio.media@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
ProgressMapperto handle terminal element offsets like/h2[1].0as well as/text()[1].0forms.<head>,<style>,<script>, and<title>while streaming EPUB HTML so CSS/metadata does not count as reading progress.idon the matched element itself, allowing heading anchors like<h2 id="...">to use the existing anchor-page lookup.