mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IGN:...
This commit is contained in:
commit
d8f2bf5367
@ -423,11 +423,13 @@ class MobiReader(object):
|
|||||||
if self.verbose:
|
if self.verbose:
|
||||||
print 'Adding anchors...'
|
print 'Adding anchors...'
|
||||||
positions = set([])
|
positions = set([])
|
||||||
link_pattern = re.compile(r'<[^<>]+filepos=[\'"]{0,1}(\d+)[^<>]*>', re.IGNORECASE)
|
link_pattern = re.compile(r'''<[^<>]+filepos=['"]{0,1}(\d+)[^<>]*>''',
|
||||||
|
re.IGNORECASE)
|
||||||
for match in link_pattern.finditer(self.mobi_html):
|
for match in link_pattern.finditer(self.mobi_html):
|
||||||
positions.add(int(match.group(1)))
|
positions.add(int(match.group(1)))
|
||||||
pos = 0
|
pos = 0
|
||||||
self.processed_html = ''
|
self.processed_html = ''
|
||||||
|
end_tag_re = re.compile(r'<\s*/')
|
||||||
for end in sorted(positions):
|
for end in sorted(positions):
|
||||||
if end == 0:
|
if end == 0:
|
||||||
continue
|
continue
|
||||||
@ -437,7 +439,8 @@ class MobiReader(object):
|
|||||||
anchor = '<a id="filepos%d"></a>'
|
anchor = '<a id="filepos%d"></a>'
|
||||||
if r > -1 and (r < l or l == end or l == -1):
|
if r > -1 and (r < l or l == end or l == -1):
|
||||||
p = self.mobi_html.rfind('<', 0, end + 1)
|
p = self.mobi_html.rfind('<', 0, end + 1)
|
||||||
if p > -1 and self.mobi_html[p + 1] != '/':
|
if pos < end and p > -1 and \
|
||||||
|
not end_tag_re.match(self.mobi_html[p:r]):
|
||||||
anchor = ' filepos-id="filepos%d"'
|
anchor = ' filepos-id="filepos%d"'
|
||||||
end = r
|
end = r
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user