Decorations are incorrectly applied to paragraphs that start with a special character
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
Research direction
Use the sample EPUB and open 05_Chapter_1_Styles_in_E.xhtml. Reproduce the issue by applying decorations to words in the described paragraph, then selecting a word and inspecting currentSelection.locator. The fix is complete when decorations align with the intended words and the selection locator’s text fields are correct.
Written by the indexing model from the issue text.
Description
Bug Report
When applying decorations to ranges that are within a paragraph that starts with a character that has a different font, the decorations are shifted with one character.
What happened?
Taking the first paragraph from a epub source file:
<p class="x03-CO-Body-Text">Everyone knows that Harry began his career in One Direction . . . or did he?! The name of his first band is super ironic considering the charmed career of charming Harry Styles—because in addition to skyrocketing, his career has gone in many directions!</p>
You can notice that the letter E is formatted differently. Because of that when applying a decoration on any of the words in this paragraph the decoration will be shifted with one character.
Example of a decoration described by locator:
{\"href\":\"/OEBPS/xhtml/05_Chapter_1_Styles_in_E.xhtml\",\"locations\":{\"progression\":0.062947067238912732,\"totalProgression\":0.2135789222699094},\"text\":{\"after\":\" his career in One Direction . . . or did he?! The name\",\"before\":\"STYLES IN EVERY DIRECTION\\n\\t\\t\\tEveryone knows that Harry \",\"highlight\":\"began\"},\"title\":\"Chapter 1: Styles in Every Direction\",\"type\":\"application/xhtml+xml\"}
Another issue us if we select a word from that paragraph. The selection Locator will describe the text but the after field has an additional character (the last character from the highlight). E.g. selecting the word "Harry" will return this Locator for the selection:
{\"href\":\"/OEBPS/xhtml/05_Chapter_1_Styles_in_E.xhtml\",\"locations\":{\"position\":6,\"progression\":0,\"totalProgression\":0.20833333333333334},\"text\":{\"after\":\"y began his career in One Direction . . . or did he?! The name of his first band is super ironic considering the charmed career of charming Harry Styles—because in addition to skyrocketing, his\",\"before\":\"CHAPTER 1\\n\\t\\t\\tSTYLES IN EVERY DIRECTION\\n\\t\\t\\tEveryone knows that\",\"highlight\":\"Harry\"},\"title\":\"Chapter 1: Styles in Every Direction\",\"type\":\"application/xhtml+xml\"}
Please find a sample epub here:
9780593383865_ewyrds_preview.epub.zip
The chapter name is 05_Chapter_1_Styles_in_E.xhtml
Expected behavior
The decorations should be properly applied and the current selection should return the correct locator.
How to reproduce?
Apply decorations for words in the mentioned paragraph and read the currentSelection.locator by selecting a word in the same paragraph.
<p class="x03-CO-Body-Text">Everyone knows that Harry began his career in One Direction . . . or did he?! The name of his first band is super ironic considering the charmed career of charming Harry Styles—because in addition to skyrocketing, his career has gone in many directions!</p>
Environment
- Readium version: 2.6.0
Development environment
macOS: 13.5.1
platform: arm64
carthage:
Xcode 14.3
Build version 14E222b
Testing device
iOS version: 16.6.1 (not OS related)
Model (e.g. iPhone 11 Pro Max): iPhone 12
Is it an emulator? No
Additional context
- Are you willing to fix the problem and contribute a pull request? Yes, with proper guidance.
- 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