## Summary * **What is the goal of this PR?** (e.g., Implements the new feature for file uploading.) Fixes footnote links landing in start section instead of the specific foot note target. * **What changes are included?** ChapterHtmlSlimParser.cpp: call flushPendingAnchor() before overwriting pendingAnchorId. First id got lost due to consecutive non-block elements carry ids, the first id was lost and the reader had no page to jump to, so it defaulted to page 0. ## Additional Context Tested with the epubs attached to to #2336. Need to clear .crosspoint/ cache after flashing so the anchor map gets rebuilt with the fix. * Add any other information that might be helpful for the reviewer (e.g., performance implications, potential risks, specific areas to focus on). --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? Partially assisted with writing documentation.
This commit is contained in:
@@ -317,6 +317,14 @@ void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char*
|
||||
const bool isTocAnchor =
|
||||
std::find(self->tocAnchors.begin(), self->tocAnchors.end(), idValue) != self->tocAnchors.end();
|
||||
if (isTocAnchor || (!isNonNavigableInlineElement(name) && self->anchorData.size() < MAX_ANCHORS_PER_CHAPTER)) {
|
||||
// Flush a displaced anchor before overwriting. Consecutive non-block elements
|
||||
// (e.g. <aside id="fn1">text</aside><aside id="fn2">) with no intervening block
|
||||
// never trigger startNewTextBlock, so fn1 gets silently overwritten. That leaves
|
||||
// fn1 missing from the anchor map -> getPageForAnchor returns nullopt -> reader
|
||||
// lands at page 0 (section start) instead of the footnote.
|
||||
if (!self->pendingAnchorId.empty()) {
|
||||
self->flushPendingAnchor();
|
||||
}
|
||||
self->pendingAnchorId = idValue;
|
||||
}
|
||||
} else if (strcmp(atts[i], "dir") == 0) {
|
||||
|
||||
Reference in New Issue
Block a user