mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
KF8 Input: Fix page breaks specified using the data-AmznPageBreak attribute being ignored by calibre.
This commit is contained in:
parent
f8de042bf1
commit
edd6d773ff
@ -74,11 +74,12 @@ def remove_kindlegen_markup(parts):
|
|||||||
part = "".join(srcpieces)
|
part = "".join(srcpieces)
|
||||||
parts[i] = part
|
parts[i] = part
|
||||||
|
|
||||||
# we can safely remove all of the Kindlegen generated data-AmznPageBreak tags
|
# we can safely remove all of the Kindlegen generated data-AmznPageBreak
|
||||||
|
# attributes
|
||||||
find_tag_with_AmznPageBreak_pattern = re.compile(
|
find_tag_with_AmznPageBreak_pattern = re.compile(
|
||||||
r'''(<[^>]*\sdata-AmznPageBreak=[^>]*>)''', re.IGNORECASE)
|
r'''(<[^>]*\sdata-AmznPageBreak=[^>]*>)''', re.IGNORECASE)
|
||||||
within_tag_AmznPageBreak_position_pattern = re.compile(
|
within_tag_AmznPageBreak_position_pattern = re.compile(
|
||||||
r'''\sdata-AmznPageBreak=['"][^'"]*['"]''')
|
r'''\sdata-AmznPageBreak=['"]([^'"]*)['"]''')
|
||||||
|
|
||||||
for i in xrange(len(parts)):
|
for i in xrange(len(parts)):
|
||||||
part = parts[i]
|
part = parts[i]
|
||||||
@ -86,10 +87,8 @@ def remove_kindlegen_markup(parts):
|
|||||||
for j in range(len(srcpieces)):
|
for j in range(len(srcpieces)):
|
||||||
tag = srcpieces[j]
|
tag = srcpieces[j]
|
||||||
if tag.startswith('<'):
|
if tag.startswith('<'):
|
||||||
for m in within_tag_AmznPageBreak_position_pattern.finditer(tag):
|
srcpieces[j] = within_tag_AmznPageBreak_position_pattern.sub(
|
||||||
replacement = ''
|
lambda m:' style="page-break-after:%s"'%m.group(1), tag)
|
||||||
tag = within_tag_AmznPageBreak_position_pattern.sub(replacement, tag, 1)
|
|
||||||
srcpieces[j] = tag
|
|
||||||
part = "".join(srcpieces)
|
part = "".join(srcpieces)
|
||||||
parts[i] = part
|
parts[i] = part
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user