readium-shared-js
readium-shared-js copied to clipboard
Sporadic CFI Parser Issue
This issue is a Bug
Sometimes when adding highlights to epub content, we get this error in the console:
SyntaxError: Expected "!/" or "/" but ")" found.
I've added as a bug here instead of readium-js-viewer since the error is originating from cfi_parser_gen.js
Expected Behaviour
Expected it to generate / parse a selection of text such that it doesn't break
Observed behaviour
Sometimes it throws the afore-mentioned error and breaks, but it's sporadic and isn't always triggered by the same events. Sometimes it happens on the first highlight, sometimes after multiple.. We are only seeing it, so far, in pages with special characters.
Steps to reproduce
- Navigate to https://readium.firebaseapp.com/?epub=epub_content%2Flinear-algebra&
- Find page(s) containing equations etc... with special characters
- Highlight all the things - around the special chars, within them (i.e. between [ and ]), through them, etc...
Product
- Readium cloud reader app
- https://readium.firebaseapp.com/?epub=epub_content%2Flinear-algebra&
- IE Edge: 25.10586.0.0 | EdgeHTML: 13.10586 | Windows 10
- Firefox 47 | Windows 7
Additional information
We just started seeing this issue - honestly unsure if issue existed previously and we just hadn't seen it, or if some updates on evergreen browsers introduced something. I've added a screenshot in hopes that it is helpful.
Thank you for this very thorough bug report (issue). We'll look into it, but unfortunately the rendering of MathML in Readium is done using Mathjax. Now Mathjax works in several ways. One of them is to render the code in HTML. Another is using SVG. For several (partially historical) reasons Readium uses the SVG output. Now the CFI parser should handle SVG as well as HTML, but I'm sure it has never been really tested with it.
Hey @rkwright thanks for the response! I actually think this bug report should've gone in the readium-cfi-js repo, and I've added a comment to the issue there back to here. While the example in the screenshot is with MathXL content, it's happening on more content - like, I've got some content where it's just text with some parenthesis and it breaks there.
@bradleygore OK. Thanks for the response. If you have non-SVG content that can reliably be reproduced, we'd love to see it. The CFI code is quite critical and used by both the native and JS stacks, so we would very much like to fix any bugs.
@rkwright Please find attached a simple epub where we're able to really consistently reproduce the issue. fixed_layout.epub.zip
Related issue: https://github.com/readium/readium-cfi-js/issues/47