diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-10-25 16:45:25 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-10-28 16:18:39 +0200 |
commit | 9f7ce17525de749758a343c03200cc40cccab056 (patch) | |
tree | fe07d380e52a60e76d3631a50f278cd3f52d3bcf /source/html/epub-doc.c | |
parent | cc3bbe49ce3fa0c99dafd4d762b8da0ecd281ff2 (diff) | |
download | mupdf-9f7ce17525de749758a343c03200cc40cccab056.tar.xz |
epub: Add links to XHTML and FB2 formats.
Diffstat (limited to 'source/html/epub-doc.c')
-rw-r--r-- | source/html/epub-doc.c | 44 |
1 files changed, 3 insertions, 41 deletions
diff --git a/source/html/epub-doc.c b/source/html/epub-doc.c index f9d9e6aa..7b44107b 100644 --- a/source/html/epub-doc.c +++ b/source/html/epub-doc.c @@ -35,48 +35,10 @@ struct epub_page_s }; static int -find_anchor_flow(fz_html_flow *flow, const char *anchor, float page_h) -{ - while (flow) - { - if (flow->box->id && !strcmp(anchor, flow->box->id)) - return flow->y / page_h; - flow = flow->next; - } - return -1; -} - -static int -find_anchor_box(fz_html_box *box, const char *anchor, float page_h) -{ - int page; - while (box) - { - if (box->id && !strcmp(anchor, box->id)) - return box->y / page_h; - if (box->type == BOX_FLOW) - { - page = find_anchor_flow(box->flow_head, anchor, page_h); - if (page >= 0) - return page; - } - else - { - page = find_anchor_box(box->down, anchor, page_h); - if (page >= 0) - return page; - } - box = box->next; - } - return -1; -} - -static int epub_resolve_link(fz_context *ctx, fz_document *doc_, const char *dest) { epub_document *doc = (epub_document*)doc_; epub_chapter *ch; - int page = -1; const char *s = strchr(dest, '#'); int n = s ? s - dest : strlen(dest); @@ -90,9 +52,9 @@ epub_resolve_link(fz_context *ctx, fz_document *doc_, const char *dest) if (s) { /* Search for a matching fragment */ - page = find_anchor_box(ch->html->root, s+1, ch->page_h); - if (page >= 0) - return ch->start + page; + float y = fz_find_html_target(ctx, ch->html, s+1); + if (y >= 0) + return ch->start + y / ch->page_h; } return ch->start; } |