From 6e8a7ce285b004c232f010a7960c4702b95710de Mon Sep 17 00:00:00 2001 From: John Schember Date: Wed, 30 Dec 2009 18:14:20 -0500 Subject: [PATCH 1/2] PML input: Use text-indent instead of margin when converting \t and \T tags. PML output: preliminary changes to support print style output (the parser needs to be rewritten to support it in a cleaner manner). --- src/calibre/ebooks/pml/pmlconverter.py | 4 ++-- src/calibre/ebooks/pml/pmlml.py | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/calibre/ebooks/pml/pmlconverter.py b/src/calibre/ebooks/pml/pmlconverter.py index 3484be5927..099a23c544 100644 --- a/src/calibre/ebooks/pml/pmlconverter.py +++ b/src/calibre/ebooks/pml/pmlconverter.py @@ -71,8 +71,8 @@ class PML_HTMLizer(object): 'ra': ('', ''), 'c': ('
', '
'), 'r': ('
', '
'), - 't': ('
', '
'), - 'T': ('
', '
'), + 't': ('
', '
'), + 'T': ('
', '
'), 'i': ('', ''), 'u': ('', ''), 'd': ('', ''), diff --git a/src/calibre/ebooks/pml/pmlml.py b/src/calibre/ebooks/pml/pmlml.py index 77f858dbc9..2e00ad6ae3 100644 --- a/src/calibre/ebooks/pml/pmlml.py +++ b/src/calibre/ebooks/pml/pmlml.py @@ -204,10 +204,12 @@ class PMLMLizer(object): tag_count = 0 # Are we in a paragraph block? - if tag in BLOCK_TAGS or style['display'] in BLOCK_STYLES: + if tag in BLOCK_TAGS:# or style['display'] in BLOCK_STYLES: if 'block' not in tag_stack: tag_count += 1 tag_stack.append('block') + if self.opts.remove_paragraph_spacing: + text.append('\\t') # Process tags that need special processing and that do not have inner # text. Usually these require an argument @@ -287,10 +289,14 @@ class PMLMLizer(object): close_tag_list.insert(0, tag_stack.pop()) text += self.close_tags(close_tag_list) if tag in SEPARATE_TAGS: - text.append('\n\n') + text.append('\n') + if not self.opts.remove_paragraph_spacing: + text.append('\n') - if 'block' not in tag_stack: - text.append('\n\n') + if 'block' not in tag_stack and text and text[-1] != '\n': + text.append('\n') + if not self.opts.remove_paragraph_spacing: + text.append('\n') #if style['page-break-after'] == 'always': # text.append('\\p') From de110a328387636bc6f4343111371ca0a35b388e Mon Sep 17 00:00:00 2001 From: John Schember Date: Fri, 1 Jan 2010 13:03:51 -0500 Subject: [PATCH 2/2] Cybook driver: Fix generating default cover when no coverdata is present. --- src/calibre/devices/cybookg3/driver.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/devices/cybookg3/driver.py b/src/calibre/devices/cybookg3/driver.py index 8f58c65ae7..c09f795627 100644 --- a/src/calibre/devices/cybookg3/driver.py +++ b/src/calibre/devices/cybookg3/driver.py @@ -49,8 +49,11 @@ class CYBOOKG3(USBMS): def upload_cover(self, path, filename, metadata): coverdata = getattr(metadata, 'thumbnail', None) if coverdata and coverdata[2]: - with open('%s_6090.t2b' % os.path.join(path, filename), 'wb') as t2bfile: - t2b.write_t2b(t2bfile, coverdata[2]) + coverdata = coverdata[2] + else: + coverdata = None + with open('%s_6090.t2b' % os.path.join(path, filename), 'wb') as t2bfile: + t2b.write_t2b(t2bfile, coverdata) @classmethod def can_handle(cls, device_info, debug=False):