mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Further improve logic for inserting Mobi filepos anchors.
This commit is contained in:
parent
88ba45cbaa
commit
7f97d458db
@ -434,16 +434,15 @@ class MobiReader(object):
|
|||||||
oend = end
|
oend = end
|
||||||
l = self.mobi_html.find('<', end)
|
l = self.mobi_html.find('<', end)
|
||||||
r = self.mobi_html.find('>', end)
|
r = self.mobi_html.find('>', end)
|
||||||
p = self.mobi_html.rfind('>', end)
|
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):
|
||||||
end = r
|
p = self.mobi_html.rfind('<', 0, end + 1)
|
||||||
anchor = ' filepos-id="filepos%d"' % oend
|
if p > -1 and self.mobi_html[p + 1] != '/':
|
||||||
elif p > pos:
|
anchor = ' filepos-id="filepos%d"'
|
||||||
end = p
|
end = r
|
||||||
anchor = ' filepos-id="filepos%d"' % oend
|
else:
|
||||||
else:
|
end = r + 1
|
||||||
anchor = '<a id="filepos%d"></a>' % oend
|
self.processed_html += self.mobi_html[pos:end] + (anchor % oend)
|
||||||
self.processed_html += self.mobi_html[pos:end] + anchor
|
|
||||||
pos = end
|
pos = end
|
||||||
self.processed_html += self.mobi_html[pos:]
|
self.processed_html += self.mobi_html[pos:]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user