-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Current Selection Locator has incorrect data describing the text #363
Comments
It looks like the WebView returns this for
But if I load the raw HTML content of the same chapter directly to the web view, this is what we get:
I didn't find what's causing this yet. I tried removing all our HTML and JavaScript injections and changing the media type (HTML instead of XHTML) returned by the HTTP server, to no avail. |
Ha, actually I used the pretty-printed version of the HTML content returned by the Web Inspector. If I try with the actual HTML that is in the EPUB, I get the same result with So to answer your issue, this is not a bug. The <?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ops="http://www.idpf.org/2007/ops">
<head>
<title>Three Tales of My Father’s Dragon</title>
<link rel="stylesheet" type="text/css" href="Gann_9780307976482_epub_css_r1.css"/>
<link rel="stylesheet" type="application/vnd.adobe-page-template+xml" href="page-template.xpgt"/>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/>
</head>
<body>
<h1 class="chapter" id="b3-c01"><a id="page155"></a><em>Chapter One</em><br/><br/>MY FATHER MEETS THE CAT</h1>
<p class="indent1"><span class="big1"><strong>O</strong></span>ne cold rainy day when my father was a little boy, he met an old alley cat on his street. The cat was very drippy and uncomfortable so my father said, “Wouldn’t you like to come home with me?”</p>
<p class="indent">This surprised the cat—she had never before met anyone who cared about old alley cats—but she said, “I’d be very much obliged if I could sit by a warm furnace, and perhaps have a saucer of milk.”</p>
<p class="indent">“We have a very nice furnace to sit by,” said my father, “and I’m sure my mother has an extra saucer of milk.”</p>
<p class="indent">My father and the cat became good friends but my father’s mother was very upset about the cat. She hated <a id="page156"></a>cats, particularly ugly old alley cats. “Elmer Elevator,” she said to my father, “if you think I’m going to give <a id="page157"></a>that cat a saucer of milk, you’re very wrong. Once you start feeding stray alley cats you might as well expect to feed every stray in town, and I am <em>not</em> going to do it!”</p>
<p class="center"><img src="images/Gann_9780307976482_epub_094_r1.jpg" alt=""/></p>
<p class="indent">This made my father very sad, and he apologized to the cat because his mother had been so rude. He told the cat to stay anyway, and that somehow he would bring her a saucer of milk each day. My father fed the cat for three weeks, but one day his mother found the cat’s saucer in the cellar and she was extremely angry. She whipped my father and threw the cat out the door, but later on my father sneaked out and found the cat. Together they went for a walk in the park and tried to think of nice things to talk about. My father said, “When I grow up I’m going to have an airplane. Wouldn’t it be wonderful to fly just anywhere you might think of!”</p>
<p class="indent">“Would you like to fly very, very much?” asked the cat.</p>
<p class="indent">“I certainly would. I’d do anything if I could fly.”</p>
<p class="center"><a id="page158"></a><img src="images/Gann_9780307976482_epub_095_r1.jpg" alt=""/></p>
<p class="indent">“Well,” said the cat, “if you’d really like to fly that much, I think I know of a sort of a way you might get <a id="page159"></a>to fly while you’re still a little boy.”</p>
<p class="indent">“You mean you know where I could get an airplane?”</p>
<p class="indent">“Well, not exactly an airplane, but something even better. As you can see, I’m an old cat now, but in my younger days I was quite a traveler. My traveling days are over but last spring I took just one more trip and sailed to the Island of Tangerina, stopping at the port of Cranberry. Well, it just so happened that I missed the boat, and while waiting for the next I thought I’d look around a bit. I was particularly interested in a place called Wild Island, which we had passed on our way to Tangerina. Wild Island and Tangerina are joined together by a long string of rocks, but people never go to Wild Island because it’s mostly jungle and inhabited by very wild animals. So I decided to go across the rocks and explore it for myself. It certainly is an interesting place, but I saw something there that made me want to weep.”</p>
<p class="center"><a id="page160"></a><img src="images/Gann_9780307976482_epub_096_r1.jpg" alt=""/></p>
</body>
</html> Why is it an issue for you and why do you need the whitespace in the |
Bug Report
In some epubs, when selecting a word in the text, the
currectSelection.locator
describes aText
element that has incorrectbefore
orafter
values (missing new lines for example)What happened?
Taking the following example: an epub chapter that starts like this
Selecting a word, "rainy" in our case. The
currentSelection.locator
looks like this:Looking at the
before
parameter, it looks like some new line characters are missingChapter OneMY FATHER MEETS THE CAT
Expected behavior
The
currentSelection.locator
should return the correctText
valueHow to reproduce?
Open the following epub, go to chapter "1. My Father Meets the Cat" and select a word from the first paragraph. Check the
currentSelection.locator.text
value.9780307976482_cewexm_preview.epub.zip
Environment
Development environment
macOS: 13.5.1
platform: arm64
carthage:
Xcode 14.3
Build version 14E222b
Testing device
Additional context
The text was updated successfully, but these errors were encountered: