Picking up some itsthisjutin ideas

This commit is contained in:
jpirnay
2026-04-19 19:03:43 +02:00
parent 174a08831d
commit d6292920d9
18 changed files with 337 additions and 41 deletions
+16
View File
@@ -65,6 +65,22 @@ class ChapterXPathIndexer {
*/
static bool tryExtractSpineIndexFromXPath(const std::string& xpath, int& outSpineIndex);
/**
* Find the full-ancestry XPath for the Nth direct-body-child <p> element.
*
* Counts only <p> elements that are direct children of <body>, matching the semantics
* of the section paragraph LUT built by ChapterHtmlSlimParser.
*
* @param epub Loaded EPUB instance
* @param spineIndex Spine item index to parse
* @param paragraphIndex 1-based paragraph index (from section LUT or XPath p[N])
* @param seekHint Optional XHTML byte offset to start scanning from (0 = from beginning).
* Pass Section::getXhtmlByteOffsetForPage() to avoid scanning the whole file.
* @return Full-ancestry XPath like "/body/DocFragment[N]/body/div[1]/p[3]", or empty on failure
*/
static std::string findXPathForParagraph(const std::shared_ptr<Epub>& epub, int spineIndex, uint16_t paragraphIndex,
uint32_t seekHint = 0, uint16_t startParagraphCount = 0);
/**
* Extract the paragraph index from a KOReader XPath.
* Looks for the first /p[N] segment after /body/ and returns N (1-based).