Open Yaco opened 4 years ago
Hm. You can use the function CFI.generate(node, offset, extra)
to generate a CFI given a reference to a node (e.g. a text node) and an optional offset into the text node, and you could do that twice for the beginning and end of the range but there is currently no function for turning those two CFIs into a range CFI.
This is definitely an oversight and needs to be added. Pull requests very welcome.
I'd look at the CFI.generatePart
function and instead of directly building the CFI in reverse order, then build the same data structure as returned by the .get
function. Once you have such a data structure for both the start and end CFIs I'd traverse these two data structures in the forward direction, comparing them and building the range CFI on piece at a time.
Hi! Just wondering if it would be possibl to use this to get cfi position (range?) of a string of text inside an ePub file?
Thanks!