From 8cb95f343bf313fdcede1bdd6c657471278cc944 Mon Sep 17 00:00:00 2001 From: Sengian Date: Mon, 26 Jul 2010 01:26:39 +0200 Subject: [PATCH] Correction of hard line breaking bug in RTF (introduce a
for \line) --- resources/templates/rtf.xsl | 4 ++ src/calibre/ebooks/rtf2xml/ParseRtf.py | 6 +- src/calibre/ebooks/rtf2xml/inline.py | 70 +++++++++++--------- src/calibre/ebooks/rtf2xml/process_tokens.py | 3 +- 4 files changed, 48 insertions(+), 35 deletions(-) diff --git a/resources/templates/rtf.xsl b/resources/templates/rtf.xsl index d2e7610661..bf016efaaf 100644 --- a/resources/templates/rtf.xsl +++ b/resources/templates/rtf.xsl @@ -412,6 +412,10 @@ page-break-after:always + + + + diff --git a/src/calibre/ebooks/rtf2xml/ParseRtf.py b/src/calibre/ebooks/rtf2xml/ParseRtf.py index 19537c708a..7b89407f79 100755 --- a/src/calibre/ebooks/rtf2xml/ParseRtf.py +++ b/src/calibre/ebooks/rtf2xml/ParseRtf.py @@ -90,8 +90,8 @@ class ParseRtf: out_file = '', out_dir = None, dtd = '', - debug = 0, - deb_dir=None, + #debug = 0, #why? calibre + deb_dir = None, convert_symbol = None, convert_wingdings = None, convert_zapf = None, @@ -132,7 +132,7 @@ class ParseRtf: self.__dtd_path = dtd self.__check_file(in_file,"file_to_parse") self.__char_data = char_data - self.__debug_dir = debug + self.__debug_dir = deb_dir #self.__debug_dir = debug calibre self.__check_dir(self.__temp_dir) self.__copy = self.__check_dir(self.__debug_dir) self.__convert_caps = convert_caps diff --git a/src/calibre/ebooks/rtf2xml/inline.py b/src/calibre/ebooks/rtf2xml/inline.py index 9f76d9858e..5ca1cd0783 100755 --- a/src/calibre/ebooks/rtf2xml/inline.py +++ b/src/calibre/ebooks/rtf2xml/inline.py @@ -1,4 +1,4 @@ -import sys, os, tempfile +import sys, os, tempfile from calibre.ebooks.rtf2xml import copy """ States. @@ -51,6 +51,7 @@ class Inline: 'tx ci - 'annotation' : 'annotation', - 'blue______' : 'blue', - 'bold______' : 'bold', - 'caps______' : 'caps', - 'char-style' : 'character-style', - 'dbl-strike' : 'double-strike-through', - 'emboss____' : 'emboss', - 'engrave___' : 'engrave', - 'font-color' : 'font-color', - 'font-down_' : 'subscript', - 'font-size_' : 'font-size', - 'font-style' : 'font-style', - 'font-up___' : 'superscript', - 'footnot-mk' : 'footnote-marker', - 'green_____' : 'green', - 'hidden____' : 'hidden', - 'italics___' : 'italics', - 'outline___' : 'outline', - 'red_______' : 'red', - 'shadow____' : 'shadow', - 'small-caps' : 'small-caps', - 'strike-thr' : 'strike-through', - 'subscript_' : 'subscript', - 'superscrip' : 'superscript', - 'underlined' : 'underlined', + # character info => ci + 'annotation' : 'annotation', + 'blue______' : 'blue', + 'bold______' : 'bold', + 'caps______' : 'caps', + 'char-style' : 'character-style', + 'dbl-strike' : 'double-strike-through', + 'emboss____' : 'emboss', + 'engrave___' : 'engrave', + 'font-color' : 'font-color', + 'font-down_' : 'subscript', + 'font-size_' : 'font-size', + 'font-style' : 'font-style', + 'font-up___' : 'superscript', + 'footnot-mk' : 'footnote-marker', + 'green_____' : 'green', + 'hidden____' : 'hidden', + 'italics___' : 'italics', + 'outline___' : 'outline', + 'red_______' : 'red', + 'shadow____' : 'shadow', + 'small-caps' : 'small-caps', + 'strike-thr' : 'strike-through', + 'subscript_' : 'subscript', + 'superscrip' : 'superscript', + 'underlined' : 'underlined', } self.__caps_list = ['false'] def __set_list_func(self, line): @@ -133,11 +135,13 @@ class Inline: Returns: nothing Logic: + Write if not hardline break """ action = self.__default_dict.get(self.__token_info) if action: action(line) - self.__write_obj.write(line) + if self.__token_info != 'cw pf 'page' : ('pf', 'page-break', self.default_func), 'par' : ('pf', 'par-end___', self.default_func),