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:
Kovid Goyal 2018-03-02 16:50:19 +05:30
parent 55ad9a3c97
commit 5e4f43588e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 3 deletions

Binary file not shown.

View File

@ -106,7 +106,8 @@ class BookIndexing
links = []
anchors = {}
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
geom = window.paged_display.column_location(a)
else
@ -118,11 +119,11 @@ class BookIndexing
if href
links.push([href, geom])
id = a.getAttribute("id")
if id and id not in anchors
if id and not anchors[id]
anchors[id] = geom
if a.tagName in ['A', "a"]
name = a.getAttribute("name")
if name and name not in anchors
if name and not anchors[name]
anchors[name] = geom
return {'links':links, 'anchors':anchors}