break
+def add_fundraising(doc, fundraising):
+ # Before each naglowek_rozdzial and naglowek_scena and in the end
+ spots = []
+ for naglowek in doc.xpath('//naglowek_czesc|//naglowek_akt'):
+ spot = etree.Element('f_spot')
+ naglowek.addprevious(spot)
+ spots.append(spot)
+ spot = etree.Element('f_spot')
+ doc.getroot()[-1][-1].append(spot)
+ spots.append(spot)
+ e = len(spots)
+ nfunds = len(fundraising)
+ if e > 4 * nfunds:
+ nfunds *= 2
+ for f in range(nfunds):
+ spot_index = int(f / nfunds * e)
+ spots[spot_index].set('active', 'true')
+ elem = etree.fromstring('<f_spot>' + fundraising[f % len(fundraising)] + '</f_spot>')
+ spots[spot_index].text = elem.text
+ for c in elem:
+ spots[spot_index].append(c)
+
+
def parse_creator(doc):
"""Generates readable versions of creator and translator tags.
def transform(wldoc, verbose=False, save_tex=None, morefloats=None,
cover=None, flags=None, customizations=None, base_url='file://./',
- latex_dir=False):
+ latex_dir=False, fundraising=None):
""" produces a PDF file with XeLaTeX
wldoc: a WLDocument
root.set('thanks', document.book_info.thanks)
# hack the tree
+ if fundraising:
+ add_fundraising(document.edoc, fundraising)
move_motifs_inside(document.edoc)
hack_motifs(document.edoc)
parse_creator(document.edoc)
</xsl:template>
+
+<xsl:template match="f_spot">
+ <xsl:if test="@active">
+ <cmd name="clearpage"/>
+ <cmd name="thispagestyle"><parm>empty</parm></cmd>
+ <cmd name="vspace*"><parm><cmd name="fill"/></parm></cmd>
+ <env name="center">
+ <env name="framed">
+ <cmd name="vspace*"><parm>2em</parm></cmd>
+ <cmd name="Large"><parm>
+ <xsl:apply-templates mode="fspot"/>
+ </parm></cmd>
+ <cmd name="vspace*"><parm>2em</parm></cmd>
+ </env>
+ </env>
+ <cmd name="vspace*"><parm><cmd name="fill"/></parm></cmd>
+ </xsl:if>
+</xsl:template>
+<xsl:template match="br" mode="fspot">
+ <TeXML escape="0">
+ \\
+ </TeXML>
+</xsl:template>
+<xsl:template match="text()" mode="fspot">
+ <xsl:value-of select="." />
+</xsl:template>
+<xsl:template match="a" mode="fspot">
+ <TeXML escape="0">\href{<xsl:value-of select="@href" />}{<TeXML escape="1"><xsl:apply-templates mode="fspot" /></TeXML>}</TeXML>
+</xsl:template>
+<xsl:template match="nbsp" mode="fspot">
+ <spec cat="tilde" />
+</xsl:template>
+
+
+
</xsl:stylesheet>