From c2d9b2e6ad47409cf135d7b619bf5aea96b6cfa5 Mon Sep 17 00:00:00 2001 From: John Schember Date: Fri, 13 Nov 2009 11:41:09 -0500 Subject: [PATCH] Fix bug #3941: Handle input with
separated paragraphs better. --- src/calibre/ebooks/fb2/fb2ml.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/fb2/fb2ml.py b/src/calibre/ebooks/fb2/fb2ml.py index 78ecc94681..41b93f6d6b 100644 --- a/src/calibre/ebooks/fb2/fb2ml.py +++ b/src/calibre/ebooks/fb2/fb2ml.py @@ -30,7 +30,7 @@ TAG_MAP = { 'i' : 'emphasis', 'p' : 'p', 'li' : 'p', - 'br' : 'empty-line', + 'br' : 'p', } TAG_SPACE = [ @@ -227,8 +227,14 @@ class FB2MLizer(object): fb2_text.append(self.get_anchor(page, id_name)) fb2_tag = TAG_MAP.get(tag, None) - if fb2_tag and fb2_tag not in tag_stack: - tag_count += 1 + if fb2_tag: + if fb2_tag not in tag_stack: + tag_count += 1 + else: + tag_stack.reverse() + tag_stack.remove(fb2_tag) + tag_stack.reverse() + fb2_text.append('' % fb2_tag) fb2_text.append('<%s>' % fb2_tag) tag_stack.append(fb2_tag)