Something went wrong. Try again.
A fork of https://github.com/crosspoint-reader/crosspoint-reader
Something went wrong. Try again.
1.5 kB · 43 lines
C
1234567891011121314151617181920212223242526272829303132333435363738394041424344#pragma once
#include <Epub.h>
#include <cstdint>#include <memory>#include <string>
class ChapterXPathResolver { public: /** * Resolve the Nth paragraph in a spine item to its real XHTML ancestry path. * * Returns a KOReader-compatible path like: * /body/DocFragment[8]/body/div[2]/section[1]/p[4] * * An empty string means parsing failed or the paragraph index was not found. */ static std::string findXPathForParagraph(const std::shared_ptr<Epub>& epub, int spineIndex, uint16_t paragraphIndex);
/** * Resolve a zero-based visible-codepoint offset in a spine item to its real * XHTML ancestry path plus text-node offset. * * Returns a KOReader-compatible path like: * /body/DocFragment[8]/body/div[2]/section[1]/p[4]/text()[1].0 * * An empty string means parsing failed or the offset did not resolve inside * paragraph/list-item text. */ static std::string findXPathForVisibleTextOffset(const std::shared_ptr<Epub>& epub, int spineIndex, uint32_t visibleTextOffset);
/** * Resolve intra-spine progress to a real XHTML ancestry path plus text offset. * * Returns a KOReader-compatible path like: * /body/DocFragment[8]/body/div[2]/section[1]/p[4]/text().96 * * An empty string means parsing failed or the location could not be resolved. */ static std::string findXPathForProgress(const std::shared_ptr<Epub>& epub, int spineIndex, float intraSpineProgress);};