From 5e4f43588e547a1a3386ad1005301b0bf4472d26 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 2 Mar 2018 16:50:19 +0530 Subject: [PATCH] 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) --- resources/compiled_coffeescript.zip | Bin 102076 -> 102048 bytes .../ebooks/oeb/display/indexing.coffee | 7 ++++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/resources/compiled_coffeescript.zip b/resources/compiled_coffeescript.zip index 846f8d323b894a4f3ef41b51934660dd83b16253..13fed66f1142106476401c7f112d3f66cec92402 100644 GIT binary patch delta 281 zcmdlpmue@+!3@`K;2?F}^6uz;JQ%t*NepOgajirI+ty;!#Y@OU}qIDvr)f ziJkm$) zj2zRYyBW2ZdvqBmKbR^qJ*Jz{i1F<7{%%GOCL`bJ6S^5irq}s0a!vo<%_zWO*U8AR zo~c@C^24dZV8e8J7=tv-O^u8bEi6*Z4ULmiQ!Oo05>wMmEi5h5l2Vc^jgyTn6D`bB zj7&|Yf9zotgP7*r$5=7Fpby9eI>C8*T^}RIC1We3VjP);?+NU@%Fc(3=AMF$1r_kC!^@}gf2$z&Htw=2yRwgzLjaR z{(Ld^%oI%p8wG>O&sHu4@mcc{b5k`ZFLV~!ymD33eO?rkrdxC|#xlKG4KZv@7o!Q| ziRll!7(JL*=rT@zFjZu_LpP%l^Gj#O>93p_Wu{N;X4GQ#^JSdw@5?AV{dPB_0Atkj zH{Fb78p$SU<`yX?$%aWLCTXUI2BwxKsg`L51_tJdmPTo*X-26=$*IPsM$;90fm*&f zGYU*E>SNTMuGGsYHod-+k!`wqAEWhjgI-3C$+?MK(|davd!|SGG73&#)x%i9SPK9$ C_F+Q+ diff --git a/src/calibre/ebooks/oeb/display/indexing.coffee b/src/calibre/ebooks/oeb/display/indexing.coffee index ecc6e6f03a..3bd8b95766 100644 --- a/src/calibre/ebooks/oeb/display/indexing.coffee +++ b/src/calibre/ebooks/oeb/display/indexing.coffee @@ -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}