def ToWLT(self, pathout=None, **kwargs): """Dump the file to a wlt file, omitting the body of the text (i.e. maxima commands only).""" oldind = copy.copy(self.ind) if not hasattr(self, "blocks"): self.FindBlocks(**kwargs) self.ind = 0 wltlines = [] for block in self.blocks: chunk = self.PopNext(clear=False, listname="rawlist") envkey, codelist = self._CleanChunk(chunk) filtcode = stripcodelist(codelist) f2code = [item.strip() for item in filtcode] wltlines.extend(f2code) self.ind = oldind # reset ind if pathout is None: pne, ext = os.path.splitext(self.path) pathout = pne + ".wlt" pytex.writefile(pathout, wltlines) wltfile = wxmlit.wxmLitFile(pathout) wltfile.ToWXM()
def EvtRunButton(self, event): #get the path to the starting wlt file wltpath = self.filechooser.GetPath() #convert to wxm and save wltfile = wxmlit.wxmLitFile(wltpath) wxmfile = wltfile.ToWXM() #wxm to LaTeX in (this is not a legitimate tex file - it includes \maxima{...} and similar environments wxmpath = wxmfile.pathin fno,ext = os.path.splitext(wxmpath) texpath = fno+'.tex' print('wxmpath='+wxmpath) print('texpath='+texpath) wlttrans = texmaxima.WLTTranslator(wltpath) wlttrans.Read() latexlist = wlttrans.Translate()#a pure Python list pytexutils.writefile(texpath, latexlist) findlist = [] self.replacelist = replacelist.ReplaceList() self.replacelist.ReadFRFile() optdict = self.latexopts.GetSettings() if optdict['usefancyhdr'] and (self.fancyhdrpanel is not None): headerlines = self.fancyhdrpanel.GetLatexLines() print('\n'*3) print('fancyhdrpanel lines:') for line in headerlines: print line print('\n'*3) inpath = texpath pno, ext = os.path.splitext(inpath) outpath2 = pno+'_out.tex' self.texmaxima = texmaxima.TexMaximaFile(inpath) self.texmaxima.RunMaxima() self.texmaxima.SubstituteLatex(echo=0, replacelist=self.replacelist) self.texmaxima.AddHeader() if optdict['usefancyhdr'] and (self.fancyhdrpanel is not None): headerlines = self.fancyhdrpanel.GetLatexLines() print('\n'*3) print('fancyhdrpanel lines:') for line in headerlines: print line print('\n'*3) self.texmaxima.HeaderInsert(headerlines) self.texmaxima.SaveLatex(filename=outpath2) maxfindlist = self.texmaxima.FindReplacePats() findlist.extend(maxfindlist) self.replacelist.AppendFRFile(findlist) if optdict['runlatex']: outputpath3 = pytexutils.RunLatex(outpath2, sourcespecials=True, log=None, **optdict) self.OutputChooser.SetPath(outputpath3) else: self.OutputChooser.SetPath(outpath2)