First attempt for proper koreader xpath generation / resolution

This commit is contained in:
jpirnay
2026-02-25 22:34:11 +01:00
parent 1ad1c2a0af
commit 7e8bd70f3c
4 changed files with 578 additions and 36 deletions
+4 -5
View File
@@ -27,9 +27,9 @@ struct KOReaderPosition {
* CrossPoint tracks position as (spineIndex, pageNumber).
* KOReader uses XPath-like strings + percentage.
*
* Since CrossPoint discards HTML structure during parsing, we generate
* synthetic XPath strings based on spine index, using percentage as the
* primary sync mechanism.
* CrossPoint first tries to extract an element-level XPath by reparsing the
* current spine XHTML and mapping intra-spine progress to text anchors.
* If extraction fails, it falls back to a synthetic chapter-level XPath.
*/
class ProgressMapper {
public:
@@ -60,8 +60,7 @@ class ProgressMapper {
private:
/**
* Generate XPath for KOReader compatibility.
* Format: /body/DocFragment[spineIndex+1]/body
* Since CrossPoint doesn't preserve HTML structure, we rely on percentage for positioning.
* Fallback format: /body/DocFragment[spineIndex]/body
*/
static std::string generateXPath(int spineIndex, int pageNumber, int totalPages);
};