fread-ink / epub-cfi-resolver

A simple parser, resolver and generator for the EPUB-CFI format
GNU Affero General Public License v3.0
19 stars 3 forks source link

undefined node after resolving CFI #8

Open mbret opened 3 years ago

mbret commented 3 years ago

For this CFI

epubcfi(/2/4/2[_preface]/10/1:175)

which points at this fragment of the epub

image

You can check the specific html for the page here

https://pastebin.com/NmW8Uz4T

I am getting an undefined node but a correct offset

image

It looks like the function getChildNodeByCFIIndex seems to fail to retrieve the TEXT_NODE for this part image

at this state image

index and cfiCount are both 1 and therefore the function return undefined. The lastChild is the TEXT_NODE

Juul commented 3 years ago

Thank you. I apologize for the delay but will investigate this soon.

Juul commented 3 years ago

I just tried running .resolveLast on the HTML you provided using the CFI you provided and it works fine for me. Can you give me the exact code you're using?

mbret commented 3 years ago

I will try again with your latest update and come back to you