PMLML: Don't write \Cn tags when we are within a heading.

This commit is contained in:
John Schember 2011-02-17 07:45:57 -05:00
parent f2dc294770
commit 1345a05339

View File

@ -258,7 +258,12 @@ class PMLMLizer(object):
# TOC markers. # TOC markers.
toc_name = elem.attrib.get('name', None) toc_name = elem.attrib.get('name', None)
toc_id = elem.attrib.get('id', None) toc_id = elem.attrib.get('id', None)
if (toc_id or toc_name) and tag not in ('h1', 'h2','h3','h4','h5','h6',): # Only write the TOC marker if the tag isn't a heading and we aren't in one.
if (toc_id or toc_name) and tag not in ('h1', 'h2','h3','h4','h5','h6') and \
'x' not in tag_stack+tags and 'X0' not in tag_stack+tags and \
'X1' not in tag_stack+tags and 'X2' not in tag_stack+tags and \
'X3' not in tag_stack+tags and 'X4' not in tag_stack+tags:
toc_page = page.href toc_page = page.href
if self.toc.get(toc_page, None): if self.toc.get(toc_page, None):
for toc_x in (toc_name, toc_id): for toc_x in (toc_name, toc_id):
@ -267,8 +272,8 @@ class PMLMLizer(object):
toc_depth = max(min(toc_depth, 4), 0) toc_depth = max(min(toc_depth, 4), 0)
text.append('\\C%s="%s"' % (toc_depth, toc_title)) text.append('\\C%s="%s"' % (toc_depth, toc_title))
# Process style information that needs holds a single tag # Process style information that needs holds a single tag.
# Commented out because every page in an OEB book starts with this style # Commented out because every page in an OEB book starts with this style.
if style['page-break-before'] == 'always': if style['page-break-before'] == 'always':
text.append('\\p') text.append('\\p')