Add case for ncx in read_file with soup=True.
parent
4cc89a10fc
commit
466bcf397b
|
@ -684,8 +684,12 @@ class Epub:
|
||||||
def read_file(self, id, *, soup=False):
|
def read_file(self, id, *, soup=False):
|
||||||
# text vs binary handled by open_file.
|
# text vs binary handled by open_file.
|
||||||
content = self.open_file(id, 'r').read()
|
content = self.open_file(id, 'r').read()
|
||||||
if soup and self.get_manifest_item(id)['media-type'] == 'application/xhtml+xml':
|
mediatype = self.get_manifest_item(id)['media-type']
|
||||||
|
if soup and mediatype == 'application/xhtml+xml':
|
||||||
return fix_xhtml(content, return_soup=True)
|
return fix_xhtml(content, return_soup=True)
|
||||||
|
if soup and mediatype == 'application/x-dtbncx+xml':
|
||||||
|
# xml because we have to preserve the casing on navMap.
|
||||||
|
return bs4.BeautifulSoup(content, 'xml')
|
||||||
return content
|
return content
|
||||||
|
|
||||||
@writes
|
@writes
|
||||||
|
@ -1161,8 +1165,7 @@ class Epub:
|
||||||
navpoint.append(child)
|
navpoint.append(child)
|
||||||
return navpoint
|
return navpoint
|
||||||
|
|
||||||
# xml because we have to preserve the casing on navMap.
|
soup = self.read_file(ncx_id, soup=True)
|
||||||
soup = bs4.BeautifulSoup(self.read_file(ncx_id), 'xml')
|
|
||||||
navmap = soup.navMap
|
navmap = soup.navMap
|
||||||
for child in list(navmap.children):
|
for child in list(navmap.children):
|
||||||
child.extract()
|
child.extract()
|
||||||
|
|
Loading…
Reference in New Issue