readium-cfi-js icon indicating copy to clipboard operation
readium-cfi-js copied to clipboard

getCurrentSelectionCfi() error with following xhtml

Open zoomiinc opened this issue 9 years ago • 8 comments

Thanks in advance for looking at this. When we're using the attached xhtml file (in a zip) we're getting this error when selecting a section that starts in the first paragraph and ends in the second paragraph: Uncaught SyntaxError: Expected "!/", "/", "[" or [0-9] but "," found.

The CFI looks like for example like this before being passed to peg$parse: epubcfi(/4,/4/1:16,/6/1:151)

Any idea how this could be fixed? Thanks in advance!

text-1.xhtml.zip

zoomiinc avatar Feb 05 '16 17:02 zoomiinc

Thanks for the feedback. What branch? (develop or master) What Readium app? (Chrome extension, cloud/web reader, native launcher) If cloud reader, what web browser?

danielweck avatar Feb 05 '16 17:02 danielweck

Oh, I apologize for forgetting this. We're using the latest readium-js directly. Tried master and develop. Happens across all browsers (tested latest FF, Chrome, Safari) Thanks in advance.

zoomiinc avatar Feb 05 '16 18:02 zoomiinc

I assigned Juan because he is pretty good at figuring out CFI -related bugs, but that does not mean he has the required free cycles to work on this now :)

danielweck avatar Feb 05 '16 18:02 danielweck

@ilern Hi, thanks for the info. Could you share a screenshot with your selection, just to make sure I reproduce it the same way? Thanks.

jccr avatar Feb 05 '16 19:02 jccr

I hope this helps: https://monosnap.com/file/lPiYEa7usEwXNGzMV7vTDSDOpqEJFB

zoomi 2016-02-05 20-21-58

zoomiinc avatar Feb 05 '16 19:02 zoomiinc

@ilern you can add screenshots / images directly into the GitHub comment box :) (I did that for you, see above)

danielweck avatar Feb 05 '16 19:02 danielweck

This seems to be a difference between the range CFI and the kind of CFI expected by whatever method is throwing that error.

The correct fix would be to change the method to accept range CFIs (which contain commas).

A quick fix, in the interim, would be to truncate the comma and everything past it.

For instance:

var cfi = '/4,/4/1:16,/6/1:151'; var truncatedCfi = cfi.split(',')[0];

console.log(truncatedCfi); // '/4'

Jonah Dempcy T 206.226.2857 | E [email protected] Follow on Facebook https://www.facebook.com/jdempcy | @jdempcy http://www.twitter.com/jdempcy | /in/jdempcy http://htmlsandbox.com/www.linkedin.com/in/jdempcy

On Fri, Feb 5, 2016 at 11:45 AM, Daniel Weck [email protected] wrote:

@ilern https://github.com/ilern you can add screenshots / images directly into the GitHub comment box :) (I did that for you, see above)

— Reply to this email directly or view it on GitHub https://github.com/readium/readium-cfi-js/issues/47#issuecomment-180517466 .

jdempcy avatar Feb 05 '16 19:02 jdempcy

I just posted a bug in the readium-shared-js repo as I didn't realize there was a separate CFI repo, but I think it's related to this issue. It has steps to reproduce on the readium firebase app as well as screenshots. Any help appreciated!

https://github.com/readium/readium-shared-js/issues/313

bradleygore avatar Aug 02 '16 19:08 bradleygore