Commits

Robert Mařík committed a0594a7

allow embeding 3d pictures created via viewer='tachyon'

  • Participants
  • Parent commits 1144ea0

Comments (0)

Files changed (1)

 import string
 import os
 import sys
+import glob
 
 from pygments import highlight
 from pygments.lexers import PythonLexer, TexLexer, HtmlLexer
         if self.text.find('<div class="docstring">') != -1:
             return "\n\n"
 
-        if self.text.strip() == "":
-            return "\n\n"
+        #if self.text.strip() == "":
+        #    return "\n\n"
 
         output_list = self.parse_output()
 
                 verbatim = True
             latex_str += "\n\n" # paragraph between <html>...</html> blocks
 
+        pictures = glob.glob("%s/sage_worksheet/cells/%s/*" % (temp_dir, self.cell_id) )
+        if pictures != []:
+            for i in pictures:
+                i = os.path.basename(i)
+                if (i[-3:] == "png" or i[-3:] == "pdf") and latex_str.find("includegraphics{sage_worksheet/cells/%s/%s}" % (self.cell_id, i)) == -1:
+                    latex_str += "\n\n\\includegraphics{sage_worksheet/cells/%s/%s}\n\n" % (self.cell_id, i)
+                elif i[-4:] == "jmol":
+                    latex_str += "\n\n\\centerline{\\color{gray}\\fbox{\\textsc{3D picture skipped}}}\n\n"
+                
         return latex_str
 
     def parse_output(self):
             language = cell_list[-1].language
             if language == 'latex':
                 current_cell = cell_list[-1].text
-            if current_cell.strip() != "":
-                cell_list.append(OutputCell(current_cell, current_cell_id, language))
+            #if current_cell.strip() != "":
+            cell_list.append(OutputCell(current_cell, current_cell_id, language))
             current_cell = ""
             continue