From d91c38e23ef889644b60edc147af325aead1ee34 Mon Sep 17 00:00:00 2001 From: Sengian Date: Fri, 16 Jul 2010 09:20:21 +0200 Subject: [PATCH] Add superscript and subscript support in RTF --- resources/templates/rtf.xsl | 21 ++++++++++++++++++++- src/calibre/ebooks/rtf/input.py | 4 +++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/resources/templates/rtf.xsl b/resources/templates/rtf.xsl index 9199654665..74696f0857 100644 --- a/resources/templates/rtf.xsl +++ b/resources/templates/rtf.xsl @@ -111,7 +111,6 @@ or (@shadow = 'true') or (@hidden = 'true') or (@outline = 'true') - "> @@ -277,6 +276,26 @@ ] + + + + + + + + + + + + + + + + + + + + diff --git a/src/calibre/ebooks/rtf/input.py b/src/calibre/ebooks/rtf/input.py index d5e1a95157..7d25f4cb86 100644 --- a/src/calibre/ebooks/rtf/input.py +++ b/src/calibre/ebooks/rtf/input.py @@ -192,6 +192,7 @@ class RTFInput(InputFormatPlugin): from calibre.ebooks.rtf2xml.ParseRtf import RtfInvalidCodeException self.log = log self.log('Converting RTF to XML...') + #Name of the preprocesssed RTF file fname = self.preprocess(stream.name) try: xml = self.generate_xml(fname) @@ -205,6 +206,7 @@ class RTFInput(InputFormatPlugin): imap = self.extract_images(d[0]) except: self.log.exception('Failed to extract images...') + self.log('Parsing XML...') parser = etree.XMLParser(recover=True, no_network=True) doc = etree.fromstring(xml, parser=parser) @@ -214,10 +216,10 @@ class RTFInput(InputFormatPlugin): name = imap.get(num, None) if name is not None: pict.set('num', name) + self.log('Converting XML to HTML...') inline_class = InlineClass(self.log) styledoc = etree.fromstring(P('templates/rtf.xsl', data=True)) - extensions = { ('calibre', 'inline-class') : inline_class } transform = etree.XSLT(styledoc, extensions=extensions) result = transform(doc)