Add anchor-based TOC navigation: parse #fragment anchors, find exact page within section
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user