mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
KF8 Output: Fix a couple of bugs that could lead to generation of invalid KF8 files. Fixes #1016672 (broken rtf to azw3 conversion)
This commit is contained in:
parent
8ffeb0c222
commit
313b4634d6
@ -111,7 +111,7 @@ class Skeleton(object):
|
||||
self.chunks = chunks
|
||||
|
||||
self.skeleton = self.render(root)
|
||||
self.body_offset = self.skeleton.find('<body')
|
||||
self.body_offset = self.skeleton.find(b'<body')
|
||||
self.calculate_metrics(root)
|
||||
|
||||
self.calculate_insert_positions()
|
||||
@ -127,7 +127,7 @@ class Skeleton(object):
|
||||
self.metrics = {}
|
||||
for tag in root.xpath('//*[@aid]'):
|
||||
text = (tag.text or '').encode('utf-8')
|
||||
raw = tostring(tag, with_tail=True)
|
||||
raw = close_self_closing_tags(tostring(tag, with_tail=True))
|
||||
start_length = len(raw.partition(b'>')[0]) + len(text) + 1
|
||||
end_length = len(raw.rpartition(b'<')[-1]) + 1
|
||||
self.metrics[tag.get('aid')] = Metric(start_length, end_length)
|
||||
|
Loading…
x
Reference in New Issue
Block a user