Add anchor-based TOC navigation: parse #fragment anchors, find exact page within section

This commit is contained in:
2026-05-22 17:56:48 +08:00
parent 21e9aba274
commit 1d2407098c
3 changed files with 109 additions and 12 deletions

View File

@@ -382,6 +382,15 @@ BgType::Custom(ref path) if !path.is_empty() => {
if let Some(section) = action.jump_to_section {
self.state.current_section = section;
self.state.current_page = 0;
if let Some(ref anchor) = action.jump_to_anchor {
if let Some(ref book) = self.state.book {
if section < book.sections.len() {
if let Some(page) = crate::reader::find_page_for_anchor(&book.sections[section], anchor) {
self.state.current_page = page;
}
}
}
}
}
if action.page_prev {