equations
authorMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Tue, 18 Sep 2012 15:38:06 +0000 (17:38 +0200)
committerMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Wed, 19 Sep 2012 12:32:31 +0000 (14:32 +0200)
Conflicts:

librarian/pdf.py
librarian/pdf/wl.cls
librarian/pdf/wl2tex.xslt

librarian/pdf.py
librarian/pdf/wl.cls
librarian/pdf/wl2tex.xslt

index ca18f70..0485613 100644 (file)
@@ -174,7 +174,8 @@ def package_available(package, args='', verbose=False):
 
 
 def transform(wldoc, verbose=False, save_tex=None, morefloats=None,
-              cover=None, flags=None, customizations=None):
+              cover=None, flags=None, customizations=None,
+              imgdir=""):
     """ produces a PDF file with XeLaTeX
 
     wldoc: a WLDocument
@@ -228,7 +229,7 @@ def transform(wldoc, verbose=False, save_tex=None, morefloats=None,
         style = etree.parse(style_filename)
 
         texml = document.transform(style)
-
+        etree.dump(texml.getroot())
         # TeXML -> LaTeX
         temp = mkdtemp('-wl2pdf')
 
@@ -236,6 +237,10 @@ def transform(wldoc, verbose=False, save_tex=None, morefloats=None,
             with open(os.path.join(temp, 'cover.jpg'), 'w') as f:
                 the_cover.save(f)
 
+        for img in document.edoc.findall('//ilustr'):
+            shutil.copy(os.path.join(imgdir, img.get('src')), temp)
+
+
         del document # no longer needed large object :)
 
         tex_path = os.path.join(temp, 'doc.tex')
@@ -271,6 +276,7 @@ def transform(wldoc, verbose=False, save_tex=None, morefloats=None,
         return OutputFile.from_filename(output_file.name)
 
     except (XMLSyntaxError, XSLTApplyError), e:
+        print e
         raise ParseError(e)
 
 
index 2ddcc71..be05aa8 100644 (file)
@@ -571,3 +571,11 @@ Letters={Uppercase}
 \fi
 }
 
+\newcommand{\ilustr}[2]{
+
+\vspace{1em}%
+\begin{center}%
+\par{\includegraphics[width=\textwidth]{#1}\\#2}%
+\end{center}%
+\vspace{1em}%
+}
index 5b58d61..f9b7ab0 100644 (file)
     </cmd>
 </xsl:template>
 
+<xsl:template match="ilustr">
+    <cmd>
+        <xsl:attribute name="name">
+            <xsl:value-of select="wl:texcommand(name())" />
+        </xsl:attribute>
+               <parm><xsl:value-of select="@src" /></parm>
+        <parm><xsl:apply-templates mode="inline" /></parm>
+    </cmd>
+</xsl:template>
+
+<xsl:template match="@*|node()" mode="identity">
+  <xsl:copy>
+    <xsl:apply-templates select="@*|node()" mode="identity"/>
+  </xsl:copy>
+</xsl:template>
+
+
+
+<xsl:template match="dmath">
+  <dmath>
+    <xsl:apply-templates mode="identity"/>
+  </dmath>
+</xsl:template>
+
+<xsl:template match="math" mode="inline">
+  <math>
+    <xsl:apply-templates mode="identity"/>
+  </math>
+</xsl:template>
+
+
 
 <!-- ================ -->
 <!-- = SPECIAL TAGS = -->