mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
EPUB3 Output: Do not split the nav HTML file in the input document, if any. Prevents duplication of nav and broken links in output nav. Fixes #2117255 [Page-list in EPUB 3 nav can be broken by conversion](https://bugs.launchpad.net/calibre/+bug/2117255)
This commit is contained in:
parent
4d4f845552
commit
1f0403dfd3
@ -14,6 +14,7 @@ import functools
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from contextlib import suppress
|
||||||
|
|
||||||
from css_selectors import Select, SelectorError
|
from css_selectors import Select, SelectorError
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
@ -64,8 +65,17 @@ class Split:
|
|||||||
self.log('Splitting markup on page breaks and flow limits, if any...')
|
self.log('Splitting markup on page breaks and flow limits, if any...')
|
||||||
self.opts = opts
|
self.opts = opts
|
||||||
self.map = {}
|
self.map = {}
|
||||||
|
nav_href = getattr(opts, 'epub3_nav_href', '')
|
||||||
|
output_supports_nav = False
|
||||||
|
with suppress(Exception):
|
||||||
|
output_supports_nav = int(opts.epub_version) >= 3
|
||||||
|
def is_nav(item):
|
||||||
|
ans = item.href == nav_href and output_supports_nav
|
||||||
|
if ans:
|
||||||
|
self.log(f'Not splitting {nav_href} as it is the EPUB3 nav document')
|
||||||
|
return ans
|
||||||
for item in list(self.oeb.manifest.items):
|
for item in list(self.oeb.manifest.items):
|
||||||
if item.spine_position is not None and etree.iselement(item.data):
|
if item.spine_position is not None and etree.iselement(item.data) and not is_nav(item):
|
||||||
self.split_item(item)
|
self.split_item(item)
|
||||||
|
|
||||||
self.fix_links()
|
self.fix_links()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user