mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add superscript and subscript support in RTF
This commit is contained in:
parent
a68fb07c41
commit
d91c38e23e
@ -111,7 +111,6 @@
|
|||||||
or (@shadow = 'true')
|
or (@shadow = 'true')
|
||||||
or (@hidden = 'true')
|
or (@hidden = 'true')
|
||||||
or (@outline = 'true')
|
or (@outline = 'true')
|
||||||
|
|
||||||
">
|
">
|
||||||
<emph rend = "paragraph-emph">
|
<emph rend = "paragraph-emph">
|
||||||
<xsl:apply-templates/>
|
<xsl:apply-templates/>
|
||||||
@ -277,6 +276,26 @@
|
|||||||
<xsl:value-of select="count(preceding::rtf:footnote) + 1"/>
|
<xsl:value-of select="count(preceding::rtf:footnote) + 1"/>
|
||||||
<xsl:text>]</xsl:text>
|
<xsl:text>]</xsl:text>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
|
<xsl:when test="(@superscript = 'true')">
|
||||||
|
<xsl:element name="sup">
|
||||||
|
<xsl:element name="span">
|
||||||
|
<xsl:attribute name="class">
|
||||||
|
<c:inline-class/>
|
||||||
|
</xsl:attribute>
|
||||||
|
<xsl:apply-templates/>
|
||||||
|
</xsl:element>
|
||||||
|
</xsl:element>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:when test="(@underscript = 'true')">
|
||||||
|
<xsl:element name="sub">
|
||||||
|
<xsl:element name="span">
|
||||||
|
<xsl:attribute name="class">
|
||||||
|
<c:inline-class/>
|
||||||
|
</xsl:attribute>
|
||||||
|
<xsl:apply-templates/>
|
||||||
|
</xsl:element>
|
||||||
|
</xsl:element>
|
||||||
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:element name="span">
|
<xsl:element name="span">
|
||||||
<xsl:attribute name="class">
|
<xsl:attribute name="class">
|
||||||
|
@ -192,6 +192,7 @@ class RTFInput(InputFormatPlugin):
|
|||||||
from calibre.ebooks.rtf2xml.ParseRtf import RtfInvalidCodeException
|
from calibre.ebooks.rtf2xml.ParseRtf import RtfInvalidCodeException
|
||||||
self.log = log
|
self.log = log
|
||||||
self.log('Converting RTF to XML...')
|
self.log('Converting RTF to XML...')
|
||||||
|
#Name of the preprocesssed RTF file
|
||||||
fname = self.preprocess(stream.name)
|
fname = self.preprocess(stream.name)
|
||||||
try:
|
try:
|
||||||
xml = self.generate_xml(fname)
|
xml = self.generate_xml(fname)
|
||||||
@ -205,6 +206,7 @@ class RTFInput(InputFormatPlugin):
|
|||||||
imap = self.extract_images(d[0])
|
imap = self.extract_images(d[0])
|
||||||
except:
|
except:
|
||||||
self.log.exception('Failed to extract images...')
|
self.log.exception('Failed to extract images...')
|
||||||
|
|
||||||
self.log('Parsing XML...')
|
self.log('Parsing XML...')
|
||||||
parser = etree.XMLParser(recover=True, no_network=True)
|
parser = etree.XMLParser(recover=True, no_network=True)
|
||||||
doc = etree.fromstring(xml, parser=parser)
|
doc = etree.fromstring(xml, parser=parser)
|
||||||
@ -214,10 +216,10 @@ class RTFInput(InputFormatPlugin):
|
|||||||
name = imap.get(num, None)
|
name = imap.get(num, None)
|
||||||
if name is not None:
|
if name is not None:
|
||||||
pict.set('num', name)
|
pict.set('num', name)
|
||||||
|
|
||||||
self.log('Converting XML to HTML...')
|
self.log('Converting XML to HTML...')
|
||||||
inline_class = InlineClass(self.log)
|
inline_class = InlineClass(self.log)
|
||||||
styledoc = etree.fromstring(P('templates/rtf.xsl', data=True))
|
styledoc = etree.fromstring(P('templates/rtf.xsl', data=True))
|
||||||
|
|
||||||
extensions = { ('calibre', 'inline-class') : inline_class }
|
extensions = { ('calibre', 'inline-class') : inline_class }
|
||||||
transform = etree.XSLT(styledoc, extensions=extensions)
|
transform = etree.XSLT(styledoc, extensions=extensions)
|
||||||
result = transform(doc)
|
result = transform(doc)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user