EPUB: a Decoration built per occurrence of a repeated phrase collapses onto one earlier occurrence
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- javascript
- Domain
- mobile
Research direction
Start by reading the vendored TextQuoteAnchor implementation and the rangeFromLocator body in Scripts/src/utils.js, then reproduce the eight-identical-refrain case described in the issue. Done means each of the eight locators resolves to its own range and each occurrence is highlighted once, rather than several resolving to the same earlier range.
Written by the indexing model from the issue text.
Description
Describe the bug
When one block repeats the same phrase with identical surrounding text (a verse refrain), building a Decoration/highlight per occurrence collapses several of them onto a single earlier occurrence — some occurrences get highlighted more than once, others never.
Expected: each occurrence resolves to its own range and is highlighted once.
How to reproduce?
Deterministic, reproduced directly against Readium's own vendored anchoring (TextQuoteAnchor + the rangeFromLocator body from Scripts/src/utils.js, 3.8.0):
- Take one block that repeats a phrase with identical context, e.g. eight lines of
the tide will turn,. - For each occurrence, build its
TextQuoteSelectorthe way a client does from a selection (TextQuoteAnchor.fromRange, 32-char prefix/suffix), then resolve it back withrangeFromLocator. - Occurrences whose ±32-char context is identical all resolve to the same earlier range. In the fixture below: 8 locators → 5 distinct ranges; #4–#6 all land on #3.
Any client that decorates each occurrence (annotations, search highlights) goes through the same rangeFromLocator, so the collapse is not specific to the harness. I have a self-contained HTML harness (opens in any browser, no build) plus a screenshot of the result and will attach them here shortly.
Readium version
3.8.0
OS version
N/A — the bug is in the injected JS anchoring layer, independent of iOS version.
Testing device
N/A — JS layer (repro run against the vendored anchoring in a browser and under Node/JSDOM).
Environment
macOS: 15.7.4
platform: arm64
Xcode 26.3
Build version 17C529
Additional context
Widening the fixed ±32-char context window does not help — a longer identical refrain defeats any fixed length. Previously raised as #860 (closed with a request to re-file per the template).
- Dominant language
- Swift
- Stars
- 557
- Forks
- 249
- Avg merge
- 3h 52m
- Merged PRs (30d)
- 19
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from readium/swift-toolkit
-
triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
readium/swift-toolkit#954 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
readium/swift-toolkit#841 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 57/100
readium/swift-toolkit#961 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
readium/swift-toolkit#959 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
readium/swift-toolkit#953 ·
Maintainers usually reply within 1 day
All issues in readium/swift-toolkit
Similar issues
-
area: models enhancement needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
rexmhall09/TUFF#69 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nikitabobko/AeroSpace#2427 · 1 comment ·
Maintainers usually reply within 8 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
A second click on the Control Center widget doesn't close Control CenterPossibly taken @MaHofseth claimed this today. Openneeds-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100