From 57a8c0e8a5b5e1f31aca1bb3a1017e40f8d41262 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 2 Apr 2015 09:21:00 +0530 Subject: [PATCH] MOBI Input: Fix links not working in viewer for MOBI files that contain anchors placed on linebreak elements. Fixes #1439450 [Private bug](https://bugs.launchpad.net/calibre/+bug/1439450) --- src/calibre/ebooks/mobi/reader/mobi6.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/mobi/reader/mobi6.py b/src/calibre/ebooks/mobi/reader/mobi6.py index 24962fc858..25fc4b6ffd 100644 --- a/src/calibre/ebooks/mobi/reader/mobi6.py +++ b/src/calibre/ebooks/mobi/reader/mobi6.py @@ -385,8 +385,7 @@ class MobiReader(object): svg_tags = [] forwardable_anchors = [] pagebreak_anchors = [] - BLOCK_TAGS = {'h1', 'h2', 'h3', 'h4', 'h5', 'h6', - 'div', 'p'} + BLOCK_TAGS = {'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'p'} for i, tag in enumerate(root.iter(etree.Element)): tag.attrib.pop('xmlns', '') for x in tag.attrib: @@ -583,6 +582,10 @@ class MobiReader(object): else: block.attrib['id'] = tag.attrib['id'] + # WebKit fails to navigate to anchors located on
tags + for br in root.xpath('/body/br[@id]'): + br.tag = 'div' + def get_left_whitespace(self, tag): def whitespace(tag):