Skip to content

Commit

Permalink
Merge pull request #287 from aerkalov/fix/win32path
Browse files Browse the repository at this point in the history
Use posix module instead of the os.path when managing EPUB references
  • Loading branch information
aerkalov authored Jul 30, 2023
2 parents a55089a + 55ae029 commit 1cb3d2c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ebooklib/epub.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,11 +1150,11 @@ def _create_section(itm, items):
if isinstance(item, tuple) or isinstance(item, list):
li = etree.SubElement(ol, 'li')
if isinstance(item[0], EpubHtml):
a = etree.SubElement(li, 'a', {'href': os.path.relpath(item[0].file_name, nav_dir_name)})
a = etree.SubElement(li, 'a', {'href': zip_path.relpath(item[0].file_name, nav_dir_name)})
elif isinstance(item[0], Section) and item[0].href != '':
a = etree.SubElement(li, 'a', {'href': os.path.relpath(item[0].href, nav_dir_name)})
a = etree.SubElement(li, 'a', {'href': zip_path.relpath(item[0].href, nav_dir_name)})
elif isinstance(item[0], Link):
a = etree.SubElement(li, 'a', {'href': os.path.relpath(item[0].href, nav_dir_name)})
a = etree.SubElement(li, 'a', {'href': zip_path.relpath(item[0].href, nav_dir_name)})
else:
a = etree.SubElement(li, 'span')
a.text = item[0].title
Expand All @@ -1163,11 +1163,11 @@ def _create_section(itm, items):

elif isinstance(item, Link):
li = etree.SubElement(ol, 'li')
a = etree.SubElement(li, 'a', {'href': os.path.relpath(item.href, nav_dir_name)})
a = etree.SubElement(li, 'a', {'href': zip_path.relpath(item.href, nav_dir_name)})
a.text = item.title
elif isinstance(item, EpubHtml):
li = etree.SubElement(ol, 'li')
a = etree.SubElement(li, 'a', {'href': os.path.relpath(item.file_name, nav_dir_name)})
a = etree.SubElement(li, 'a', {'href': zip_path.relpath(item.file_name, nav_dir_name)})
a.text = item.title

_create_section(nav, self.book.toc)
Expand Down Expand Up @@ -1205,7 +1205,7 @@ def _create_section(itm, items):
guide_type = elem.get('type', '')
a_item = etree.SubElement(li_item, 'a', {
'{%s}type' % NAMESPACES['EPUB']: guide_to_landscape_map.get(guide_type, guide_type),
'href': os.path.relpath(_href, nav_dir_name)
'href': zip_path.relpath(_href, nav_dir_name)
})
a_item.text = _title

Expand Down Expand Up @@ -1240,7 +1240,7 @@ def _create_section(itm, items):
_title = label

a_item = etree.SubElement(li_item, 'a', {
'href': os.path.relpath(_href, nav_dir_name),
'href': zip_path.relpath(_href, nav_dir_name),
})
a_item.text = _title

Expand Down

0 comments on commit 1cb3d2c

Please sign in to comment.