From 981e64c9683e8187bba50bad43b934ad9ddc7a50 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 4 Dec 2007 20:15:56 +0000 Subject: [PATCH] Fix #344 --- src/libprs500/ebooks/lrf/html/convert_from.py | 18 ++++++++++++++++-- src/libprs500/ebooks/lrf/pylrs/pylrs.py | 8 -------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/libprs500/ebooks/lrf/html/convert_from.py b/src/libprs500/ebooks/lrf/html/convert_from.py index 3d2a1d3640..b4631b2daf 100644 --- a/src/libprs500/ebooks/lrf/html/convert_from.py +++ b/src/libprs500/ebooks/lrf/html/convert_from.py @@ -37,7 +37,7 @@ from libprs500.ebooks.BeautifulSoup import BeautifulSoup, Comment, Tag, \ from libprs500.ebooks.lrf.pylrs.pylrs import Paragraph, CR, Italic, ImageStream, \ TextBlock, ImageBlock, JumpButton, CharButton, \ Plot, Image, BlockSpace, RuledLine, BookSetting, Canvas, DropCaps, \ - LrsError, Sup, Sub, properties_different, EmpLine + LrsError, Sup, Sub, EmpLine from libprs500.ebooks.lrf.pylrs.pylrs import Span from libprs500.ebooks.lrf import Book, entity_to_unicode from libprs500.ebooks.lrf import option_parser as lrf_option_parser @@ -200,7 +200,7 @@ class HTMLConverter(object): self.memory = [] #: Used to ensure that duplicate CSS unhandled erros are not reported self.tops = {} #: element representing the top of each HTML file in the LRF file self.previous_text = '' #: Used to figure out when to lstrip - self.preserve_block_style = False #: Used so that

tags in

elements are handles properly + self.preserve_block_style = False #: Used so that

tags in

elements are handled properly # Styles self.blockquote_style = book.create_block_style(sidemargin=60, topskip=20, footskip=20) @@ -1195,6 +1195,20 @@ class HTMLConverter(object): block_properties = self.block_properties(tag_css) align = self.get_alignment(tag_css) + def fill_out_properties(props, default): + for key in default.keys(): + if not props.has_key(key): + props[key] = default[key] + + fill_out_properties(block_properties, self.book.defaultBlockStyle.attrs) + fill_out_properties(text_properties, self.book.defaultTextStyle.attrs) + + def properties_different(dict1, dict2): + for key in dict1.keys(): + if dict1[key] != dict2[key]: + return True + return False + if properties_different(self.current_block.blockStyle.attrs, block_properties) or \ properties_different(self.current_block.textStyle.attrs, text_properties) or\ align != self.current_block.textStyle.attrs['align']: diff --git a/src/libprs500/ebooks/lrf/pylrs/pylrs.py b/src/libprs500/ebooks/lrf/pylrs/pylrs.py index 69cd3ce541..338659c4a8 100644 --- a/src/libprs500/ebooks/lrf/pylrs/pylrs.py +++ b/src/libprs500/ebooks/lrf/pylrs/pylrs.py @@ -2459,11 +2459,3 @@ class Font(LrsContainer): element = Element("RegistFont", encoding="TTF", fontname=self.facename, file=self.filename, fontfilename=self.filename) return element - - - -def properties_different(attrs1, attrs2): - for key in attrs1.keys(): - if attrs2.has_key(key) and str(attrs1[key]) != str(attrs2[key]): - return True - return False \ No newline at end of file