Partial fix for blank line in RTFInput

This commit is contained in:
Sengian 2011-01-16 12:05:00 +01:00
parent f22868e769
commit c81f75f6f6
2 changed files with 9 additions and 33 deletions

View File

@ -220,7 +220,7 @@
</xsl:template>
<xsl:template name="parse-styles-attrs">
<!--<xsl:text>position:relative;</xsl:text>-->
<!--<xsl:text>position:relative;</xsl:text>
<xsl:if test="@space-before">
<xsl:text>padding-top:</xsl:text>
<xsl:value-of select="@space-before"/>
@ -230,7 +230,7 @@
<xsl:text>padding-bottom:</xsl:text>
<xsl:value-of select="@space-after"/>
<xsl:text>pt;</xsl:text>
</xsl:if>
</xsl:if>-->
<xsl:if test="@left-indent">
<xsl:text>padding-left:</xsl:text>
<xsl:value-of select="@left-indent"/>
@ -260,11 +260,11 @@
<xsl:text>text-decoration:underline</xsl:text>
<xsl:text>;</xsl:text>
</xsl:if>
<xsl:if test="@line-spacing">
<!--<xsl:if test="@line-spacing">
<xsl:text>line-height:</xsl:text>
<xsl:value-of select="@line-spacing"/>
<xsl:text>pt;</xsl:text>
</xsl:if>
</xsl:if>-->
<xsl:if test="(@align = 'just')">
<xsl:text>text-align: justify;</xsl:text>
</xsl:if>
@ -314,7 +314,6 @@
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

View File

@ -78,13 +78,14 @@ class RTFInput(InputFormatPlugin):
def generate_xml(self, stream):
from calibre.ebooks.rtf2xml.ParseRtf import ParseRtf
ofile = 'dataxml.xml'
run_lev, debug_dir = 1, None
run_lev, debug_dir, indent_out = 1, None, 0
#just to check if the debug process is lauched, no need of this directory in fact
if getattr(self.opts, 'debug_pipeline', None) is not None:
try:
os.mkdir('rtfdebug')
debug_dir = 'rtfdebug'
run_lev = 4
indent_out = 1
except:
pass
parser = ParseRtf(
@ -108,7 +109,7 @@ class RTFInput(InputFormatPlugin):
# Indent resulting XML.
# Default is 0 (no indent).
indent = 1,
indent = indent_out,
# Form lists from RTF. Default is 1.
form_lists = 1,
@ -157,34 +158,10 @@ class RTFInput(InputFormatPlugin):
with open(name, 'wb') as f:
f.write(data)
imap[count] = name
#open(name+'.hex', 'wb').write(enc)
# with open(name+'.hex', 'wb') as f:
# f.write(enc)
return self.convert_images(imap)
# count = 0
# raw = open(picts, 'rb').read()
# starts = []
# for match in re.finditer(r'\{\\pict([^}]+)\}', raw):
# starts.append(match.start(1))
# imap = {}
# for start in starts:
# pos, bc = start, 1
# while bc > 0:
# if raw[pos] == '}': bc -= 1
# elif raw[pos] == '{': bc += 1
# pos += 1
# pict = raw[start:pos+1]
# enc = re.sub(r'[^a-zA-Z0-9]', '', pict)
# if len(enc) % 2 == 1:
# enc = enc[:-1]
# data = enc.decode('hex')
# count += 1
# name = (('%4d'%count).replace(' ', '0'))+'.wmf'
# open(name, 'wb').write(data)
# imap[count] = name
# #open(name+'.hex', 'wb').write(enc)
# return self.convert_images(imap)
def convert_images(self, imap):
self.default_img = None
for count, val in imap.iteritems():