diff --git a/resources/templates/rtf.xsl b/resources/templates/rtf.xsl index 7d48418776..61474701dc 100644 --- a/resources/templates/rtf.xsl +++ b/resources/templates/rtf.xsl @@ -1,7 +1,7 @@ - - - - - + + + + + + +   + + + @@ -149,7 +154,7 @@ - unamed + unnamed @@ -445,7 +450,10 @@ - # + + # + + diff --git a/src/calibre/ebooks/rtf/input.py b/src/calibre/ebooks/rtf/input.py index c1e649851b..5858824434 100644 --- a/src/calibre/ebooks/rtf/input.py +++ b/src/calibre/ebooks/rtf/input.py @@ -305,11 +305,13 @@ class RTFInput(InputFormatPlugin): html = 'index.xhtml' with open(html, 'wb') as f: res = transform.tostring(result) - res = res[:100].replace('xmlns:html', 'xmlns') + res[100:] + # res = res[:100].replace('xmlns:html', 'xmlns') + res[100:] + #clean multiple \n + res = re.sub('\n+', '\n', res) # Replace newlines inserted by the 'empty_paragraphs' option in rtf2xml with html blank lines - res = re.sub('\s*', '', res) - res = re.sub('(?<=\n)\n{2}', - u'

\u00a0

\n'.encode('utf-8'), res) + # res = re.sub('\s*', '', res) + # res = re.sub('(?<=\n)\n{2}', + # u'

\u00a0

\n'.encode('utf-8'), res) f.write(res) self.write_inline_css(inline_class, border_styles) stream.seek(0) diff --git a/src/calibre/ebooks/rtf2xml/ParseRtf.py b/src/calibre/ebooks/rtf2xml/ParseRtf.py index e442a1c496..40945be975 100755 --- a/src/calibre/ebooks/rtf2xml/ParseRtf.py +++ b/src/calibre/ebooks/rtf2xml/ParseRtf.py @@ -376,13 +376,13 @@ class ParseRtf: msg += 'self.__run_level is "%s"\n' % self.__run_level raise RtfInvalidCodeException, msg if self.__run_level > 1: - sys.stderr.write(_('File could be older RTF...\n')) + sys.stderr.write('File could be older RTF...\n') if found_destination: if self.__run_level > 1: - sys.stderr.write(_( + sys.stderr.write( 'File also has newer RTF.\n' 'Will do the best to convert.\n' - )) + ) add_brackets_obj = add_brackets.AddBrackets( in_file = self.__temp_file, bug_handler = RtfInvalidCodeException, diff --git a/src/calibre/ebooks/rtf2xml/add_brackets.py b/src/calibre/ebooks/rtf2xml/add_brackets.py index a7888f32b8..d4919d4cd7 100755 --- a/src/calibre/ebooks/rtf2xml/add_brackets.py +++ b/src/calibre/ebooks/rtf2xml/add_brackets.py @@ -11,11 +11,11 @@ # # # # ######################################################################### -import sys, os, tempfile +import sys, os, tempfile + from calibre.ebooks.rtf2xml import copy, check_brackets # note to self. This is the first module in which I use tempfile. A good idea? -""" -""" + class AddBrackets: """ Add brackets for old RTF. @@ -41,6 +41,7 @@ class AddBrackets: self.__copy = copy self.__write_to = tempfile.mktemp() self.__run_level = run_level + def __initiate_values(self): """ """ @@ -82,14 +83,16 @@ class AddBrackets: 'cw