diff --git a/src/calibre/ebooks/rtf2xml/ParseRtf.py b/src/calibre/ebooks/rtf2xml/ParseRtf.py index 442f5f4ac3..a28b6f81da 100755 --- a/src/calibre/ebooks/rtf2xml/ParseRtf.py +++ b/src/calibre/ebooks/rtf2xml/ParseRtf.py @@ -375,7 +375,7 @@ class ParseRtf: old_rtf = old_rtf_obj.check_if_old_rtf() if old_rtf: if self.__run_level > 5: - msg = 'older RTF\n' + msg = 'Older RTF\n' msg += 'self.__run_level is "%s"\n' % self.__run_level raise RtfInvalidCodeException, msg if self.__run_level > 1: diff --git a/src/calibre/ebooks/rtf2xml/delete_info.py b/src/calibre/ebooks/rtf2xml/delete_info.py index b3b5bdcad7..80d2a2b2bd 100755 --- a/src/calibre/ebooks/rtf2xml/delete_info.py +++ b/src/calibre/ebooks/rtf2xml/delete_info.py @@ -48,6 +48,7 @@ class DeleteInfo: 'cw%s' '%snone\n' % (type, my_string)) return my_changed_string + def __found_toc_index_func(self, line, tag): """ Requires: @@ -382,6 +397,7 @@ file. self.__cb_count = 0 self.__state = 'toc_index' self.__tag = tag + def __toc_index_func(self, line): """ Requires: @@ -409,6 +425,7 @@ file. self.__write_obj.write(line) else: self.__text_string += line + def fix_fields(self): """ Requires: @@ -423,24 +440,19 @@ file. bookmark. """ self.__initiate_values() - read_obj = open(self.__file) - self.__write_obj = open(self.__write_to, 'w') - line_to_read = '1' - while line_to_read: - line_to_read = read_obj.readline() - line = line_to_read - self.__token_info = line[:16] - if self.__token_info == 'ob", input_file) input_file = self.__ms_hex_exp.sub("\\mshex0\g<1> ", input_file) input_file = self.__utf_ud.sub("\\{\\uc0 \g<1>\\}", input_file) #remove \n in bin data @@ -172,6 +172,8 @@ class Tokenize: self.__splitexp = re.compile(r"(\\[{}]|\n|\\[^\s\\{}&]+(?:[ \t\r\f\v])?)") #this is for old RTF self.__par_exp = re.compile(r'\\\n+') + #handle improper cs char-style with \* before without { + self.__cs_ast = re.compile(r'\\\*([\n ]*\\cs\d+[\n \\]+)') # self.__par_exp = re.compile(r'\\$') #self.__bin_exp = re.compile(r"\\bin(-?\d{1,8}) {0,1}") #self.__utf_exp = re.compile(r"^\\u(-?\d{3,6})")