mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
PDF Output: When the input document contains multiple anchors with the same value, use the first anchor rather than the last. This follows browser behavior. Fixes #1752825 [Private bug](https://bugs.launchpad.net/calibre/+bug/1752825)
This commit is contained in:
parent
55ad9a3c97
commit
5e4f43588e
Binary file not shown.
@ -106,7 +106,8 @@ class BookIndexing
|
|||||||
links = []
|
links = []
|
||||||
anchors = {}
|
anchors = {}
|
||||||
in_paged_mode = window.paged_display?.in_paged_mode
|
in_paged_mode = window.paged_display?.in_paged_mode
|
||||||
for a in document.querySelectorAll("body a[href], body [id], body a[name]")
|
|
||||||
|
for a in document.querySelectorAll("body, body a[href], body [id], body a[name]")
|
||||||
if in_paged_mode
|
if in_paged_mode
|
||||||
geom = window.paged_display.column_location(a)
|
geom = window.paged_display.column_location(a)
|
||||||
else
|
else
|
||||||
@ -118,11 +119,11 @@ class BookIndexing
|
|||||||
if href
|
if href
|
||||||
links.push([href, geom])
|
links.push([href, geom])
|
||||||
id = a.getAttribute("id")
|
id = a.getAttribute("id")
|
||||||
if id and id not in anchors
|
if id and not anchors[id]
|
||||||
anchors[id] = geom
|
anchors[id] = geom
|
||||||
if a.tagName in ['A', "a"]
|
if a.tagName in ['A', "a"]
|
||||||
name = a.getAttribute("name")
|
name = a.getAttribute("name")
|
||||||
if name and name not in anchors
|
if name and not anchors[name]
|
||||||
anchors[name] = geom
|
anchors[name] = geom
|
||||||
|
|
||||||
return {'links':links, 'anchors':anchors}
|
return {'links':links, 'anchors':anchors}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user