mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix KF8 internal links
This commit is contained in:
parent
03a6e4ad62
commit
2e30c49e3f
@ -369,7 +369,7 @@ def count_set_bits(num):
|
||||
def to_base(num, base=32, min_num_digits=None):
|
||||
digits = string.digits + string.ascii_uppercase
|
||||
sign = 1 if num >= 0 else -1
|
||||
if num == 0: return '0'
|
||||
if num == 0: return ('0' if min_num_digits is None else '0'*min_num_digits)
|
||||
num *= sign
|
||||
ans = []
|
||||
while num:
|
||||
|
@ -366,7 +366,7 @@ class Chunker(object):
|
||||
def to_placeholder(aid):
|
||||
pos, fid = aid_map[aid]
|
||||
pos, fid = to_base(pos, min_num_digits=4), to_href(fid)
|
||||
return bytes(':'.join((pos, fid)))
|
||||
return bytes(':off:'.join((pos, fid)))
|
||||
|
||||
placeholder_map = {bytes(k):to_placeholder(v) for k, v in
|
||||
self.placeholder_map.iteritems()}
|
||||
@ -376,12 +376,12 @@ class Chunker(object):
|
||||
raw = match.group()
|
||||
pl = match.group(1)
|
||||
try:
|
||||
return raw[:-15] + placeholder_map[pl]
|
||||
return raw[:-19] + placeholder_map[pl]
|
||||
except KeyError:
|
||||
pass
|
||||
return raw
|
||||
|
||||
return re.sub(br'<[^>]+(kindle:pos:fid:0000:\d{10})', sub, text)
|
||||
return re.sub(br'<[^>]+(kindle:pos:fid:0000:off:[0-9A-Za-z]{10})', sub, text)
|
||||
|
||||
def dump(self, orig_dumps):
|
||||
import tempfile, shutil, os
|
||||
|
Loading…
x
Reference in New Issue
Block a user