Skip to content

Commit 05a1943

Browse files
andyrobertsaerkalov
authored andcommitted
Fixed aerkalov#85 - Epub2 guide types do not map completely to epub3 landmark types
small changes
1 parent e902111 commit 05a1943

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ebooklib/epub.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,13 @@ def _create_section(itm, items):
764764
# - http://www.idpf.org/epub/30/spec/epub30-contentdocs.html#sec-xhtml-nav-def-types-landmarks
765765

766766
if len(self.book.guide) > 0 and self.options.get('epub3_landmark'):
767+
768+
# Epub2 guide types do not map completely to epub3 landmark types.
769+
guide_to_landscape_map = {
770+
'notes': 'rearnotes',
771+
'text': 'bodymatter'
772+
}
773+
767774
guide_nav = etree.SubElement(body, 'nav', {'{%s}type' % NAMESPACES['EPUB']: 'landmarks'})
768775

769776
guide_content_title = etree.SubElement(guide_nav, 'h2')
@@ -783,7 +790,8 @@ def _create_section(itm, items):
783790
_href = elem.get('href', '')
784791
_title = elem.get('title', '')
785792

786-
a_item = etree.SubElement(li_item, 'a', {'{%s}type' % NAMESPACES['EPUB']: elem.get('type', ''), 'href': _href})
793+
guide_type = elem.get('type', '')
794+
a_item = etree.SubElement(li_item, 'a', {'{%s}type' % NAMESPACES['EPUB']: guide_to_landscape_map.get(guide_type, guide_type), 'href': _href})
787795
a_item.text = _title
788796

789797
tree_str = etree.tostring(root, pretty_print=True, encoding='utf-8', xml_declaration=True)

0 commit comments

Comments
 (0)