From 762581f1c540f7d03207e7e7f18d0c6d46639e24 Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 4 Jan 2010 07:53:27 -0500 Subject: [PATCH] PML Output: Fix tag order. Clean up block delimination code. --- src/calibre/ebooks/pml/pmlml.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/calibre/ebooks/pml/pmlml.py b/src/calibre/ebooks/pml/pmlml.py index aa14c560de..4f3d5f23df 100644 --- a/src/calibre/ebooks/pml/pmlml.py +++ b/src/calibre/ebooks/pml/pmlml.py @@ -211,11 +211,7 @@ class PMLMLizer(object): # Are we in a paragraph block? if tag in BLOCK_TAGS or style['display'] in BLOCK_STYLES: - if 'block' not in tag_stack+tags: - tags.append('block') - else: - # Start new block - text.append('\n\n') + tags.append('block') # Process tags that need special processing and that do not have inner # text. Usually these require an argument @@ -293,9 +289,6 @@ class PMLMLizer(object): if tag in SEPARATE_TAGS: text.append('\n\n') - if 'block' not in tag_stack+tags: - text.append('\n\n') - #if style['page-break-after'] == 'always': # text.append('\\p') @@ -305,9 +298,10 @@ class PMLMLizer(object): return text def close_tags(self, tags): - text = [u''] - for i in range(0, len(tags)): - tag = tags.pop() - if tag != 'block': + text = [] + for tag in tags: + if tag == 'block': + text.append('\n\n') + else: text.append('\\%s' % tag) return text