Changes

Jump to navigation Jump to search
=Introduction=
 
'''After [http://www.ntg.nl/EuroTeX2009 eurotex meeting 2009],
I'm going to fix some typos here and there and
maybe expand some examples too. I estimated that around 20 September article and site will be in synch.'''
 
 
----
'''!! W A R N I N G !! '''
* ghostscript 8.64 ✔ [[#Ghostscript|here]]
* graphviz 2.24.0 ✔ [[#Graphviz|here]]
* ImageMagick-6.4.9 with pythonmagickwand ✔[[#ImageMagick|here]]
* fontforge 20090224 ✔ [[#Fontforge|here]] Useful to check symbols collision, and if one want to play with the last fontforge, eg to draw the outline of a glyph .
* R-2.8.1 with rpy2-2.0.3 (For Maurizio "Mau" Himmelman , GUIT) ✔ [[#R|here]] (see someone says also [http://micahelliott.com/2009/03/considering-r-as-python-supplement hereconsidering-r-as-python-supplement ]) .* quantlib 0.9.7 ✔ (need an example with output in pdf)* dbxml-2.4.16 (and sqlite) [[#dbxml|here]]
= Dedicated systems =
$HOME_LUN/sage/local/bin/python setup.py build
cd $HOME_LUN
mkdir tests-SAGEMATH && cd tests-SAGEMATH
##
## I have already installed prev. python.so, I don't want mess things
For more infos, see [http://root.cern.ch here] ([http://root.cern.ch/cgi-bin/print_hit_bold.pl/root/HowtoPyROOT.html?python#first_hit here] for python stuffs).
Under Linux installation is not difficult at all, so but in this case I choose to not create a luatex-lunatic apart, as done above for sagemath.<br/>See an example [[#ROOT| here]] .
= ConTeXt mkIV examples=This example shot how to literally embedHere I will collect some tex snippets,just to show some ideasoriginal python source code .
== Scipy ==Watch how python code <tttable> z = x*np.exp(-x**2-y**2) </tttr>is translated in lua code <tttd> z = x.__mul__( np.exp( (x.__pow__(2).__add__(y.__pow__(2))).__neg__() ) )</tt>  {| class="wikitable" |-|<texcode>
\startluacode
function testSCIPYtest_ROOT(figname,dpifilename)
require("python")
pg = python.globals()
python.apply = python.eval('apply') or {}
np = python.import("numpy")
mlab = python.import("matplotlib.mlab")
griddata = mlab.griddata
plt = python.import("matplotlib.pyplot")
ma = np.ma
random = python.import("numpy.random")
uniform = random.uniform
-- make up some randomly distributed data npts = 200 x = uniform(-2,2,npts) y = uniform(-2,2,npts) -- z = x*nppython.expexecute(-x**2-y**2)[[ z = x.__mul__( np.exp( (x.__pow__def run(2).__add__(y.__pow__(2))).__neg__() ) ) -- define grid. xi = np.linspace(-2.1,2.1,100filename): yi = np.linspace(-2.1 from ROOT import TCanvas,2.1,100)TGraph -- grid the data. from ROOT import gROOT zi = griddata(x,y,z,xi,yi) from math import sin -- contour the gridded data, plotting dots from array import array -- at the randomly spaced data points. -- we put this in python globals space -- CS = plt gROOT.contourReset(xi,yi,zi,15,linewidths=0.5,colors='k') pg.xi = xi ; pg.yi = yi ; pg.zi = zi args c1 = python.evalTCanvas("[xi,yi,zi,15]") kv = python.eval("{'linewidthc1': 0.5 ,'colors' :'kA Simple Graph Example'}") CS = python.apply(plt.contour, args,kv) -- pg.jet = plt.cm.jet args = python.eval("[xi200,yi10,zi700,15]"500 ) kv = python.eval("{'cmap': jet}") CS = python c1.applySetFillColor(plt.contourf, args,kv42 ) -- draw colorbar plt c1.colorbarSetGrid() -- plot data points. pg.x n = x; pg.y = y 20 args = python.eval("[ x,y]") kv = python.evalarray("{'marker': 'od'), array( 'cd':'b','s':5}") CS = python.apply(plt.scatter, args,kv) plt.xlim(-2,2) plt.ylim for i in range(-2,2n ): plt x.titleappend(string0.format('griddata test (%1*i points)',npts)) --plt y.savefigappend(figname, dpi, 'white') -- pg.figname = figname ; pg.dpi = dpi args = python.eval10*sin("x[fignamei]") kv = python+0.eval("{'dpi': dpi ,'facecolor' :'white'}"2 ) CS = python.apply(plt.savefig, args,kv)end\stopluacode
gr = TGraph( n, x, y ) gr.SetLineColor( 2 ) gr.SetLineWidth( 4 ) gr.SetMarkerColor( 4 ) gr.SetMarkerStyle( 21 ) gr.SetTitle( 'a simple graph' ) gr.GetXaxis().SetTitle( 'X title' )\def\testSCIPY[#1]{% gr.GetYaxis().SetTitle( 'Y title' ) gr.Draw( 'ACP' ) c1.Update() c1.Print(filename)\getparameters[scipy][#1]%)\ctxlua{testSCIPY run = pg.run run("\csname scipyfigname\endcsname",filename) "\csname scipydpi\endcsname")}%end\externalfigure[\csname scipyfigname\endcsname]%}stopluacode
\starttext
\startTEXpage
\testSCIPYctxlua{test_ROOT("testsin.pdf")}\rotate[fignamerotation=90]{test-scipy-1\externalfigure[testsin.pdf},dpi][width={1505cm]}]
\stopTEXpage
\stoptext
</texcode>|| </td><td> [[Image:Test-scipyTestsin.pngjpg|600px512px]] </td> </tr></table>|}We can do a bit better: separate python code from lua code .<br/>Save this in <tt>test-ROOT1.py</tt> (so it's also easy to test) :<pre>from ROOT import TCanvas, TGraph ,TGraphErrors,TMultiGraphfrom ROOT import gROOTfrom math import sinfrom array import array
def run(filename): c1 == Python Imaging Library TCanvas("c1","multigraph",200,10,700,500) c1.SetGrid(PIL) ==
{| class # draw a frame to define the range mg = TMultiGraph() # create first graph n = 24; x = array('d',range(24)) data = file('data').readlines() for line in data: line = line.strip() y = array('d',[float(d) for d in line.split()]) gr = TGraph(n,x,y) gr.Fit("pol6","wikitableq" ) mg.Add(gr)  mg.Draw("ap")  #force drawing of canvas to generate the fit TPaveStats c1.Update() c1.Print(filename) </pre>Here file 'data' is a 110 lines file with 24 floats values space separated,ie <br/><tt> 20.6000 19.4000 19.4000 18.3000 17.8000 16.1000 16.7000 21.1000 23.3000 26.1000 26.1000 27.2000 27.8000 28.3000 28.3000 27.2000 25.6000 22.8000 21.7000 21.7000 21.7000 21.7000 21.7000 21.7000 </tt>.<br/>Now a tex file, with a simple layer in lua as interface for python:{||-|<texcode>
\startluacode
function testPILtest_ROOT(imageorig,imagesepiafilename)
require("python")
PIL_Image test = python.import("PIL.Image") PIL_ImageOps = python.import("PIL.ImageOps"'test-ROOT1') python.execute([[def make_linear_ramp(white): ramp = [] r, g, b = white for i in range(255): ramp.extend((r*i/255, g*i/255, b*i/255)) return ramp]]) -- make sepia ramp (tweak color as necessary) sepia = python.eval("make_linear_ramp((255, 240, 192))") im = PIL_Image.open(imageorig) -- convert to grayscale if not(im.mode == "L") then im = im.convert("L") end -- optional: apply contrast enhancement here, e.g. im = PIL_ImageOps.autocontrast(im)  -- apply sepia palette im.putpalette(sepia)  -- convert back to RGB so we can save it as JPEG -- (alternatively, save it in PNG or similar) im = im.convert("RGB")  imtest.saverun(imagesepiafilename)end
\stopluacode
\defstarttext\SepiaImage#1#2{%startTEXpage\ctxlua{testPILtest_ROOT("#1","#2data.pdf")}%\startcombinationrotate[2*1rotation=90]{\externalfigure[#1]}{\ss Origdata.}{\externalfigure[#2pdf]}{\ss Sepia}\stopcombination}  \starttext\startTEXpage\SepiaImage{lena.jpg}{lena-sepia.jpg}
\stopTEXpage
\stoptext
</texcode> || [[Image:Test-PILROOT1.pngjpg|330px300px]]
|}
=ConTeXt mkIV examples= ROOT Here I will collect some tex snippets,just to show some ideas. == Scipy ==This example shot Watch how to literally embedpython code <tt> z = x*np.exp(-x**2-y**2) </tt>original python source is translated in lua code <tt> z = x.__mul__( np.exp( (x.__pow__(2).__add__(y.__pow__(2))).__neg__() ) )</tt> 
{|class="wikitable"
|-
|<texcode>
\startluacode
function test_ROOTtestSCIPY(filenamefigname,dpi)
require("python")
pg = python.globals()
python.apply = python.eval('apply') or {}
np = python.import("numpy")
mlab = python.import("matplotlib.mlab")
griddata = mlab.griddata
plt = python.import("matplotlib.pyplot")
ma = np.ma
random = python.import("numpy.random")
uniform = random.uniform
python-- make up some randomly distributed data npts = 200 x = uniform(-2,2,npts) y = uniform(-2,2,npts) -- z = x*np.executeexp([[-x**2-y**2)def run z = x.__mul__( np.exp( (x.__pow__(2).__add__(y.__pow__(2))).__neg__(filename):) ) -- define grid. from ROOT import TCanvas xi = np.linspace(-2.1,2.1, TGraph100) from ROOT import gROOT yi = np.linspace(-2.1,2.1,100) -- grid the data. from math import sin zi = griddata(x,y,z,xi,yi) from array import array -- contour the gridded data, plotting dots -- at the randomly spaced data points. -- we put this in python globals space gROOT -- CS = plt.Resetcontour(xi,yi,zi,15,linewidths=0.5,colors='k') pg.xi = xi ; pg.yi = yi ; pg.zi = zi args = python.eval("[xi,yi,zi,15]") c1 kv = TCanvaspython.eval( "{'c1linewidth': 0.5 , 'A Simple Graph Examplecolors':'k'}") CS = python.apply(plt.contour, args, 200kv) -- pg.jet = plt.cm.jet args = python.eval("[xi, 10yi, 700zi, 500 15]") kv = python.eval("{'cmap': jet}") c1 CS = python.SetFillColorapply( 42 plt.contourf, args,kv) c1 -- draw colorbar plt.SetGridcolorbar() -- plot data points. n pg.x = x; pg.y = 20y args = python.eval("[x, y ]") kv = arraypython.eval("{'marker': 'o', 'c':'b','s':5}") CS = python.apply(plt.scatter, args,kv) plt.xlim(-2,2) plt.ylim(-2,2) plt.title(string.format( 'dgriddata test (%i points)' ,npts)) --plt.savefig(figname, dpi, array'white') -- pg.figname = figname ; pg.dpi = dpi args = python.eval("[figname]") kv = python.eval( "{'dpi'd: dpi ,' facecolor' :'white'}") CS = python.apply(plt.savefig, args,kv)end\stopluacode
for i in range( n ): x.append( 0.\def\testSCIPY[#1*i )]{% y.append( 10*sin( x\getparameters[scipy][i#1]+0.2 ) )%  gr = TGraph\ctxlua{testSCIPY( n"\csname scipyfigname\endcsname", x, y ) gr.SetLineColor( 2 ) gr.SetLineWidth( 4 ) gr.SetMarkerColor( 4 ) gr.SetMarkerStyle( 21 ) gr.SetTitle( 'a simple graph' ) gr.GetXaxis().SetTitle( 'X title' ) gr.GetYaxis().SetTitle( 'Y title' ) gr.Draw( 'ACP' ) c1.Update() c1.Print(filename "\csname scipydpi\endcsname")}%\externalfigure[\csname scipyfigname\endcsname]]) run = pg.run run(filename)end%\stopluacode}
\starttext
\startTEXpage
\ctxluatestSCIPY[figname={test_ROOT("testsintest-scipy-1.pdf")}\rotate[rotation,dpi=90]{\externalfigure[testsin.pdf][width=5cm150}]}
\stopTEXpage
\stoptext
</texcode> || [[Image:TestsinTest-scipy.jpgpng|512px600px]]
|}
We can do a bit better: separate python code from lua code .<br/>Save this in <tt>test-ROOT1.py</tt> == Python Imaging Library (so it's also easy to testPIL) :<pre>from ROOT import TCanvas, TGraph ,TGraphErrors,TMultiGraphfrom ROOT import gROOTfrom math import sinfrom array import array==
def run{| class="wikitable" |-|<texcode>\startluacodefunction testPIL(filenameimageorig,imagesepia): c1 = TCanvas require("c1python",) PIL_Image = python.import("multigraphPIL.Image",200,10,700,500) c1 PIL_ImageOps = python.SetGridimport("PIL.ImageOps") python.execute([[ # draw a frame to define the range mg = TMultiGraphdef make_linear_ramp(white): # create first graphramp = [] n r, g, b = 24;white x = array('d',for i in range(24)255): data = file ramp.extend(('data'r*i/255, g*i/255, b*i/255).readlines() for line in data:return ramp]]) line = line.strip -- make sepia ramp (tweak color as necessary) y sepia = arraypython.eval("make_linear_ramp('d'(255, 240,[float(d192))") for d in line im = PIL_Image.splitopen(imageorig)]) gr -- convert to grayscale if not(im.mode == TGraph(n,x,y"L") then grim = im.Fitconvert("pol6L") end -- optional: apply contrast enhancement here,"q")e.g. mg im = PIL_ImageOps.Addautocontrast(grim)
mg-- apply sepia palette im.Drawputpalette("ap"sepia)
#force drawing of canvas -- convert back to generate the fit TPaveStatsRGB so we can save it as JPEG c1-- (alternatively, save it in PNG or similar) im = im.Updateconvert("RGB"c1im.Printsave(filenameimagesepia)end\stopluacode \def\SepiaImage#1#2{%\ctxlua{testPIL("#1","#2")}%\startcombination[2*1]{\externalfigure[#1]}{\ss Orig.}{\externalfigure[#2]}{\ss Sepia}\stopcombination}
</pre>
Here file 'data' is a 110 lines file with 24 floats values space separated,
ie <br/><tt> 20.6000 19.4000 19.4000 18.3000 17.8000 16.1000 16.7000 21.1000 23.3000 26.1000 26.1000 27.2000 27.8000 28.3000 28.3000 27.2000 25.6000 22.8000 21.7000 21.7000 21.7000 21.7000 21.7000 21.7000 </tt>.<br/>
Now a tex file, with a simple layer in lua as interface for python:
{|
|-
|<texcode>
\startluacode
function test_ROOT(filename)
require("python")
test = python.import('test-ROOT1')
test.run(filename)
end
\stopluacode
\starttext
\startTEXpage
\ctxluaSepiaImage{test_ROOT("datalena.pdf")jpg}\rotate[rotation=90]{\externalfigure[datalena-sepia.pdf]jpg}
\stopTEXpage
\stoptext
</texcode> || [[Image:Test-ROOT1PIL.jpgpng|300px330px]]
|}
== Fontforge ==
In this example, we will use Metapost to draw a bezier curve of a glyph (''Note: starting from Metapost 1.200 it is now possible to get the actual path drawing routines from a font glyph, so this example is only to show how to translate a path in metapost'').<br/>
We will use 3-layer approach:
# a python layer that export a class,
# a lua layer to manage objects of this class
# a (con)TeX(t) layer that exports macros, because tex works very well with macros .
Let== ImageMagick ==''ImageMagick® '' ([http://www.imagemagick.org/script/index.php here]) ''is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. Use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.''s start with There are at least two python codebindings, <tt>test-fontforgeand this time I consider[http://www.procoders.py<net/tt>:?p=39 PythonMagickWand] which is a binding "ala" ctypes way . Code is simple<pretexcode>import sys\usetypescriptfile[type-gentium]\usetypescript[gentium]\setupbodyfont[gentium,10pt]import fontforge\setuppapersize[A5][A5]\setuplayout[height=middle,topspace=1cm,header={2\lineheight},footer=0pt,backspace=1cm,margin=1cm, width=middle]
class simpledraw\startluacodefunction testimagemagick(objectbox,t): local w local h local d local f local res = 118.11023622047244094488 -- 300 dpi local opacity = 25 local sigma = 15 local x = 10 local y = 10
def __init__ require(self,font_file"python") pg = python.globals() PythonMagickWand = python.import("PythonMagickWand") w = math.floor((tex.wd[box] / 65536 ) / 72.27 * 2.54 * res ): self h = math.floor(((tex.ht[box] / 65536) + (tex.font dp[box] / 65536)) / 72.27 *2.54 *res ) f = fontforgestring.openformat(font_file"%s.png",t)
def getcurve wand = PythonMagickWand.NewMagickWand(self,letter): self background = PythonMagickWand.glname = letter res = dictNewPixelWand(0) try : glyph_letter = [ g for g in self -- PythonMagickWand.font.glyphsMagickNewImage() if g.glyphname == self.glname][0] except Exception wand,w,h,e : res['err'] = str(ebackground) return res cnt= glyph_letter.layers[1][0] res['is_quadratic'] = cnt.is_quadratic res['closed'] = cnt PythonMagickWand.closed res['points'] = [MagickNewImage(p.xwand,w,p.yh,"%i" %p.on_curvebackground) for p in cnt ] res['design_size'] = self.font.design_size res['em'] = self.font.em return res
PythonMagickWand.MagickSetImageResolution(wand,res,res)
PythonMagickWand.MagickSetImageUnits(wand,PythonMagickWand.PixelsPerCentimeterResolution)
PythonMagickWand.MagickShadowImage(wand,opacity,sigma,x,y)
PythonMagickWand.MagickWriteImage(wand ,f)
def getmpostoutline print(selfw,letter): res = self.getcurve(letterh,f) path = '..'.join( [str((p[0],p[1])) for p in res['points'] if p[2] == '1'] )end return path\stopluacode
def getmpostpoints(self,letter):
res = self.getcurve(letter)
path = [str((p[0],p[1])) for p in res['points'] if p[2] == '1']
return path
def getmpostpointsSugar(self,letter):
res = self.getcurve(letter)
path = 'drawdot '.join( ["%s;" %str((p[0],p[1])) for p in res['points'] if p[2] == '1'] )
return 'drawdot ' +path
\def\testimagemagick[#1]{%
\getparameters[imagemagick][#1]%
\ctxlua{testimagemagick(\csname imagemagickbox\endcsname,"\csname imagemagickfilename\endcsname")}%
}
if __name__ \newcount\shdw\long\def\startShadowtext#1\stopShadowtext{%\bgroup%\setbox0=\vbox{#1}%\testimagemagick[box=0,filename= '__main__':{shd-\the\shdw}]%%% s = simpledraw("koeieletters\defineoverlay[backg][{\externalfigure[shd-\the\shdw.pfb")png]}]% res \framed[background=backg,frame=off,offset= s.getmpostpointsSugar('C')4pt]{\box0}%%%\framed{\box0}\global\advance\shdw by 1% print res\egroup%</pre>}
Note the <tt>'__main__'</tt> check, so we can test this class from python. <br/>Next lua layer, which in this case is embed in a tex file:<texcode>\startluacodefunction testFontforge(fontfile,letter) require("python") testoutlines = python.import("test-fontforge") s = testoutlines.simpledraw(fontfile) g = s.getmpostoutline(letter) p = s.getmpostpointsSugar(letter) tex.sprint(tex.ctxcatcodes,"\\startMPcode") tex.sprint(tex.ctxcatcodes,"pickup pencircle scaled 1pt;") tex.sprint(tex.ctxcatcodes,string.format("draw %s .. cycle;",g) ) tex.sprint(tex.ctxcatcodes,"pickup pencircle scaled 8pt;") tex.sprint(tex.ctxcatcodes,string.format("%s",p) ) tex.sprint(tex.ctxcatcodes,"\\stopMPcode")end\stopluacode  \def\Outline[#1]{%\getparameters[test][#1]%\ctxlua{testFontforge("\testfontfile", "\testletter")}%} \starttext\startTEXpage\Outline[letter={C}, fontfile={lmmono10-regular.otf}]%\Outline[letter={o}, fontfile={lmmono10-regular.otf}]startShadowtext%\Outline[letter={n}, fontfile={lmmono10-regular.otf}]%\Outline[letter={T}, fontfile={lmmono10-regular.otf}]%\Outline[letter={e}, fontfile={lmmono10-regular.otf}]%\Outline[letter={X}, fontfile={lmmono10-regular.otf}]%input tufte\Outline[letter={t}, fontfile={lmmono10-regular.otf}]stopShadowtext%
\stopTEXpage
\stoptext
</texcode>
And here is the result:
Here we use <tt>tex.sprint(tex.ctxcatcodes,"\\stopMPcode")</tt> to inject tex code (actually Metapost code) into TeX parser .<br/><tt>\Outline</tt> is the TeX layer: of course one can write <tt>\Outline</tt> and <tt>testFontforge</tt> in a different manner to avoid use of tex.sprint(..) <br/>And this is the result: <br/>[[Image:Test-fontforgeimagemagick.png|900px]] ...ok,it's not correct (why?), but it looks funny :)
== Ghostscript Fontforge ==There are essentially 2 kind of In this example, we will use Metapost to draw a bezier curve of ghostscript a glyph (''Note:* convert an existing eps / ps file in pdf ;* use starting from Metapost 1.200 it is now possible to get the actual path drawing routines from a program in postscript that take an inputfont glyph, do something and make so this example is only to show how to translate a ps output ( e.g. a barcode/label generator path in metapost''). For the first case, we consider an implementation of eps2pdf, being ps2pdf virtually the same .<br/>Actually there is not We will use 3-layer approach:# a python binding of ghostscriptlayer that export a class, so we build # a simple wrapper lua layer to manage objects of this classusing ctypes module# a (con)TeX(t) layer that exports macros, because tex works very well with macros .
Let's start with python code, <tt>test-fontforge.py</tt>:
<pre>
import ctypes
import sys
import fontforge
 
 
class simpledraw(object):
def __init__(self,font_file):
self.font = fontforge.open(font_file)
class gs def getcurve(objectself,letter): self.glname = letter res_Array = [] res = dict() try : #glyph_letter = [ g for g in self.font.glyphs() if g.glyphname == self.glname][0] g = self.font[letter] except Exception ,e : res['err'] = str(e) res_Array.append(res) return res_Array layer_idx = 0; for layer_name in g.layers: layer = g.layers[layer_name] for contour_idx in range(len(layer)): res = dict() contour = layer[contour_idx] contour_name = contour.name res['name'] = contour.name res['is_quadratic'] = contour.is_quadratic res['closed'] = contour.closed res['points'] = [(p.x,p.y,"%i" %p.on_curve) for p in contour ] res['design_size'] = self.font.design_size res['em'] = self.font.em res_Array.append(res) return res_Array
def __init__(self):
def drawmpostpath(self,letter): res_Array = self.ierrors = dictgetcurve(letter) self.ierrors['e_unknownerror'] state = -1 0 self.ierrors[ paths = 'e_dictfull'] for res in res_Array: temp = -2 self.ierrors['e_dictstackoverflow'] = -3 self.ierrors for p in res['e_dictstackunderflowpoints'] = -4: self.ierrors if p['e_execstackoverflow'2] = -5 self.ierrors[='e_interrupt1'] : if state == -61 : self.ierrors[ temp = temp + 'e_invalidaccess-- (%s,%s)'%(p[0] = -7 self.ierrors,p['e_invalidexit'1] ) ; state = -81; continue else: self temp = temp + '..ierrors(%s,%s)' %(p['e_invalidfileaccess'0] = -9 self.ierrors,p['e_invalidfont'1] ) ; state = -101; continue self if state == 1 : temp = temp + ' ..ierrorscontrols (%s,%s)' %(p['e_invalidrestore'0] = -11 self.ierrors,p['e_ioerror'1] ) ; state = -122; continue self.ierrors['e_limitcheck'] if state = -13 self.ierrors['e_nocurrentpoint'] = -14 self.ierrors['e_rangecheck'] 2 : temp = -15 self.ierrors[temp + 'e_stackoverflowand (%s,%s) '] = -16 self.ierrors%(p['e_stackunderflow'0] = -17 self.ierrors,p['e_syntaxerror'1] ) ; state = -180; continue self.ierrors if res['e_timeoutclosed'] = -19 : self.ierrors['e_typecheck'] if state = -20 self.ierrors['e_undefined'] = -211 : self.ierrors['e_undefinedfilename'] temp = -22 self.ierrors['e_undefinedresultdraw '] = -23 self.ierrors+ temp['e_unmatchedmark'2:] = + " -24 self.ierrors['e_VMerror'] = -25cycle;\n" self.ierrors['e_configurationerror'] = -26 else: self.ierrors['e_undefinedresource'] temp = -27 self.ierrors['e_unregistereddraw '] = -28 self.ierrors+ temp['e_invalidcontext'2:] = -29 self+ " .ierrors['e_invalidid'] = -30 self.ierrors['e_Fatal'] = -100cycle;\n" self.ierrors['e_Quit'] = -101 else: self.ierrors['e_InterpreterExit'] temp = -102 self.ierrors['e_RemapColordraw '] = -103 self.ierrors+ temp['e_ExecStackUnderflow'2:] = -104+ ";\n" self.ierrors['e_VMreclaim'] paths = -105paths + temp self.ierrors['e_NeedInput'] = -106 return paths self.ierrors['e_Info'] = -110
self.libgspath = '/opt/luatex/luatex-lunatic/lib/libgs.so'
def drawmpostpoints(self,letter): res_Array = self.OutFile getcurve(letter) dots = '' self for res in res_Array: temp = '\n'.InFile join( ["drawdot %s;" %str((p[0],p[1])) for p in res['points'] if p[2] == '1'] ) + "\n" dots = dots + temp return dots
self.args = []
def appendargs(self,arg):
if arg.find('-sOutputFile')>= 0: return
if arg.find('-c quit')>= 0: return
self.args.append(arg)
if __name__ == '__main__':
s = simpledraw("lmmono10-regular.otf")
#res = s.getmpostpointsSugar('C')
#print res
#print s.getmpostoutline('C')
print s.getcurve('e')
print s.drawmpostpath('e')
print s.drawmpostpoints('e')
def rawappendargs(self,arg): self.args.append(arg)</pre>
Note the <tt>'__main__'</tt> check, so we can test this class from python. <br/>
Next lua layer, which in this case is embed in a tex file:
<texcode>
\setupcolors[state=start]
def run(self):
libgs = ctypes.CDLL(self.libgspath)
exit_status \startluacodefunction testFontforge(fontfile,letter) require("python") testoutlines = ctypespython.c_intimport("test-fontforge") code s = ctypestestoutlines.c_intsimpledraw(1fontfile) code1 g = ctypess.c_intdrawmpostpath(letter) instance p = ctypess.c_void_pdrawmpostpoints(Noneletter) exit_code --print( string.format("\%s = ctypes\%s ==", letter,g )) tex.sprint(tex.ctxcatcodes,"\\startMPcode") tex.sprint(tex.ctxcatcodes,"pickup pencircle scaled 1pt;") tex.sprint(tex.ctxcatcodes,string.format("\%s",g) ) tex.sprint(tex.ctxcatcodes,"pickup pencircle scaled 8pt;") tex.sprint(tex.ctxcatcodes,string.format("\%s",p) ) tex.c_intsprint(tex.ctxcatcodes,"\\stopMPcode")end\stopluacode
code.value = libgs.gsapi_new_instance(ctypes.byref(instance), None) if code.value == 0 :\def\Outline[#1]{% libgs.gsapi_set_stdio(instance, None, None, None) self.args.insert(0,'') \getparameters[test][# if len(self.OutFile) > 0: self.args.append('-sOutputFile=%s' 1]%self.OutFile) if len(self.InFile) > 0: self.args.append\ctxlua{testFontforge("%s\testfontfile", "\testletter" )}%self.InFile) self.args.append('-c quit') arguments = self.args # argc = ctypes.c_int(len(arguments)) argv = (ctypes.c_char_p * argc.value)(*arguments) code.value = libgs.gsapi_init_with_args(instance, argc, argv)}
code1\starttext\startTEXpage\Outline[letter={C}, fontfile={lmmono10-regular.otf}]%\Outline[letter={o}, fontfile={lmmono10-regular.otf}]%\Outline[letter={n}, fontfile={lmmono10-regular.otf}]%\Outline[letter={T}, fontfile={lmmono10-regular.value otf}]%\Outline[letter={e}, fontfile={lmmono10-regular.otf}]%\Outline[letter={X}, fontfile={lmmono10-regular.otf}]%\Outline[letter={t}, fontfile= libgs{lmmono10-regular.gsapi_exit(instance)otf}]%\stopTEXpage\stoptext</texcode>
if Here we use <tt>tex.sprint(tex.ctxcatcodes,"\\stopMPcode")</tt> to inject tex code(actually Metapost code) into TeX parser .value == 0 or code<br/><tt>\Outline</tt> is the TeX layer: of course one can write <tt>\Outline</tt> and <tt>testFontforge</tt> in a different manner to avoid use of tex.sprint(.value == self.ierrors) <br/>And this is the result: <br/>[['e_Quit']Image: codeTest-fontforge.value = code1.valuepng|900px]]
if code.value == selfGhostscript ==There are essentially 2 kind of use of ghostscript :* convert an existing eps / ps file in pdf ;* use a program in postscript that take an input, do something and make a ps output ( e.g. a barcode/label generator ). For the first case, we consider an implementation of eps2pdf, being ps2pdf virtually the same .ierrors['e_Quit']:<br/>Actually there is not a python binding of ghostscript, so we build a simple wrapper codeusing ctypes module <tt>testgs.value = 0 py</tt> :
libgs.gsapi_delete_instance(instance)<pre>import ctypesimport sys
exit_status.value = 0
if __name__ == '__main__': pyctyps = class gs(object) pyctyps.appendargs('-q') pyctyps.appendargs('-dNOPAUSE') pyctyps.appendargs('-dEPSCrop') pyctyps.appendargs('-sDEVICE=pdfwrite') pyctyps.InFile = 'test.eps' pyctyps.OutFile = 'test.pdf' pyctyps.run():
</pre> def __init__(self):
The tex code self.ierrors = dict() self.ierrors['e_unknownerror'] = -1 self.ierrors['e_dictfull'] = -2 self.ierrors['e_dictstackoverflow'] = -3 self.ierrors['e_dictstackunderflow'] = -4 self.ierrors['e_execstackoverflow'] = -5 self.ierrors['e_interrupt'] = -6 self.ierrors['e_invalidaccess'] = -7 self.ierrors['e_invalidexit'] = -8 self.ierrors['e_invalidfileaccess'] = -9<texcode> self.ierrors['e_invalidfont'] = -10\startluacode self.ierrors['e_invalidrestore'] = -11function testgs(epsin,pdfout) self.ierrors['e_ioerror'] = -12 require("python") self.ierrors['e_limitcheck'] = -13 gsmodule self.ierrors['e_nocurrentpoint'] = python-14 self.import("testgs") ierrors['e_rangecheck'] = -15 ghost self.ierrors['e_stackoverflow'] = gsmodule-16 self.gs()ierrors['e_stackunderflow'] = -17 ghost self.appendargs(ierrors['e_syntaxerror'] = -q18 self.ierrors[')e_timeout'] = -19 ghost self.appendargs(ierrors['e_typecheck'] = -dNOPAUSE20 self.ierrors[')e_undefined'] = -21 ghost self.appendargs(ierrors['e_undefinedfilename'] = -dEPSCrop22 self.ierrors[')e_undefinedresult'] = -23 ghost self.appendargs(ierrors['e_unmatchedmark'] = -sDEVICE24 self.ierrors['e_VMerror'] =pdfwrite-25 self.ierrors[')e_configurationerror'] = -26 ghost self.InFile ierrors['e_undefinedresource'] = epsin-27 ghost self.OutFile ierrors['e_unregistered'] = pdfout-28 ghost self.run()ierrors['e_invalidcontext'] = -29end self.ierrors['e_invalidid'] = -30\stopluacode self.ierrors['e_Fatal'] = -100 self.ierrors['e_Quit'] = -101\def\epstopdf#1#2{\ctxlua{testgs("#1","#2")}} self.ierrors['e_InterpreterExit'] = -102\def\EPSfigure self.ierrors[#1'e_RemapColor']{%lazy way to load eps= -103\epstopdf{#1 self.eps}{#1ierrors['e_ExecStackUnderflow'] = -104 self.pdf}%ierrors['e_VMreclaim'] = -105\externalfigure self.ierrors[#1'e_NeedInput'] = -106 self.pdfierrors['e_Info']%= -110  self.libgspath = '/opt/luatex/luatex-lunatic/lib/libgs.so'} self.OutFile = '' self.InFile = ''
\starttext\startTEXpage\startcombination[2*1]{\EPSfigure[tiger]}{\ss tiger.eps}{\EPSfigure[golfer]}{\ss golfer self.eps}\stopcombination\stopTEXpage\stoptext</texcode>and the result :<br/>args = [[Image:Testgs.png|900px]]
Another example:<br/>here we use a library to generate barcodes [http://www.terryburton.co.uk/barcodewriter (see here)] .<texcode>\startluacodefunction epstopdf(epsin,pdfout) require("python") gsmodule = python.import("testgs") ghost = gsmodule.gs() ghost. def appendargs('-q'self,arg): ghost if arg.appendargsfind('-dNOPAUSEsOutputFile')>= 0: return ghost if arg.appendargsfind('-dEPSCropc quit') ghost.appendargs('-sDEVICE>=pdfwrite') ghost.InFile = epsin0: return ghost self.OutFile = pdfout ghostargs.runappend(arg)end
function barcode(text,type,options,savefile)
require("python")
gsmodule = python.import("testgs")
barcode_string = string.format def rawappendargs("%%!\n100 100 moveto (%sself,arg) : self.args.append(%s) %s barcode showpage" ,text,options,typearg)
psfile = string.format("%s.ps",savefile)
epsfile = string.format("%s.eps",savefile)
pdffile = string.format("%s.pdf",savefile)
temp = io.open(psfile,'w')
temp:write(tostring(barcode_string),"\n")
temp:flush()
io.close(temp)
ghost = gsmodule.gs()
ghost.rawappendargs('-q')
ghost.rawappendargs('-dNOPAUSE')
ghost.rawappendargs('-sDEVICE=epswrite')
ghost.rawappendargs(string.format('-sOutputFile=%s',epsfile))
ghost.rawappendargs('barcode.ps')
ghost.InFile= psfile
ghost.run()
end
\stopluacode
\ def\epstopdf#1#2{\ctxlua{epstopdfrun(self): libgs = ctypes.CDLL("#1","#2"self.libgspath)}}\def\EPSfigure[#1]{%lazy way to load eps\epstopdf{#1 exit_status = ctypes.c_int() code = ctypes.eps}{#c_int(1) code1 = ctypes.pdf}%c_int()\externalfigure[#1 instance = ctypes.pdf]%c_void_p(None)} exit_code = ctypes.c_int()
\def\PutBarcode[#1]{%
\getparameters[bc][#1]%
\ctxlua{barcode("\csname bctext\endcsname","\csname bctype\endcsname","\csname bcoptions\endcsname","\csname bcsavefile\endcsname" )}%
\expanded{\EPSfigure[\csname bcsavefile\endcsname]}%
}
\starttext\startTEXpage\startcombination[2*2]{\PutBarcode[text code.value ={CODE 39}libgs.gsapi_new_instance(ctypes.byref(instance),typeNone) if code.value ={code39},options={includecheck includetext},savefile={TEMP1}]}{\ss code39}0 :{\PutBarcode[text={CONTEXT} libgs.gsapi_set_stdio(instance,type={code93}None,options={includecheck includetext}None,savefile={TEMP2}]}{\ss code93}None){\PutBarcode[text={977147396801} self.args.insert(0,type'') # if len(self.OutFile) > 0: self.args.append('-sOutputFile={ean13},options%s' %self.OutFile) if len(self.InFile) > 0: self.args.append("%s" %self.InFile) self.args.append('-c quit') arguments ={includetext},savefileself.args # argc ={TEMP3}]}{\ss ean13}ctypes.c_int(len(arguments)){\PutBarcode[text argv ={0123456789},type(ctypes.c_char_p * argc.value)(*arguments) code.value ={interleaved2of5}libgs.gsapi_init_with_args(instance,options={includecheck includetext}argc,savefile={TEMP4}]}{\ss interleaved2of5}\stopcombination\stopTEXpage\stoptext</texcode>argv)
[[Image:Test-ghostscript-barcode code1.png|900px]]value = libgs.gsapi_exit(instance)
if code.value == Graphviz 0 or code.value == self.ierrors[http'e_Quit']://www.graphviz.org Graphviz] is a Graph Visualization Software .<br/>Standard distribution comes with several binding (lua and python among others) so it's not difficult to integrate in luatex lunatic code.<br/>In this example, we draw a graph of the nodes of <context>\TeX</context><pre>\def\StudyBox#1{%\startluacoderequire "python"gv value = pythoncode1.import("gv")g = gv.digraph("G")gv.setv(g,'rankdir','LR')value
nodes if code.value = nodes or {}= self.ierrors['e_Quit']: code.value = 0
local nd = {};local kd = {}; libgs.gsapi_delete_instance(instance)
local k exit_status.value = 0;local function nodesprint(head,n) while head do local id = head.id local oldn = n ndlbl = string.format("nd_\%03d",k) texio.write_nl(string.format("id=\%s, ndlbl=\%s",id,ndlbl))
if id __name__ == node.id("vlist") then k = k + 1'__main__': nd[n] pyctyps = gv.nodegs(g,ndlbl) res = gv pyctyps.setvappendargs(nd[n],"shape","record"'-q') res = gv pyctyps.setvappendargs(nd[n],"label",tostring(k'-dNOPAUSE') .. " " .. "vlist" pyctyps.. "\|id:" .. tostringappendargs(head.id'-dEPSCrop') .. "\|subtype:" pyctyps.. tostringappendargs(head.subtype'-sDEVICE=pdfwrite') .. "\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") pyctyps.InFile = 'test. eps' "\|width:" .. tostring(head.width) pyctyps.OutFile = 'test. pdf' "\|depth:" pyctyps.. tostringrun(head.depth) .. "\|height:" .. tostring(head.height) .. "\|dir:" .. tostring(head.dir) .. "\|shift:" .. tostring(head.shift) .. "\|glue_order:" .. tostring(head.glue_order) .. "\|glue_sign:" .. tostring(head.glue_sign) .. "\|glue_set:" .. tostring(head.glue_set) .. "\|list:" .. string.gsub(tostring(head.list),"([><])","\\\%1") .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") .. "\|next:" .. string.gsub(tostring(head.next),"([/pre><])","\\\%1")) end
if id The tex code<texcode>\startluacodefunction testgs(epsin,pdfout) require("python") gsmodule == nodepython.idimport("ruletestgs") then k ghost = k + 1gsmodule.gs() ghost.appendargs('-q') nd[n] = gv ghost.nodeappendargs(g,ndlbl'-dNOPAUSE') res = gv ghost.setvappendargs('-dEPSCrop') ghost.appendargs('-sDEVICE=pdfwrite') ghost.InFile = epsin ghost.OutFile = pdfout ghost.run()end\stopluacode \def\epstopdf#1#2{\ctxlua{testgs(nd[n],"shape#1","record#2")}} res = gv.setv(nd\def\EPSfigure[n#1],"label",tostring(k) {%lazy way to load eps\epstopdf{#1.eps}{#1. " " .. "rule" .pdf}%\externalfigure[#1. pdf]%}  "\|id:" .. tostring(head.id) .. starttext "\|subtype:" .. tostring(head.subtype) startTEXpage\startcombination[2*1]{\EPSfigure[tiger]}{\ss tiger.eps}{\EPSfigure[golfer]}{\ss golfer. eps} "\stopcombination\stopTEXpage\stoptext</texcode>and the result :<br/>[[Image:Testgs.png|attr900px]] Another example:<br/>here we use a library to generate barcodes [http:" //www.terryburton. stringco.gsubuk/barcodewriter (tostringsee here)] .<texcode>\startluacodefunction epstopdf(head.attrepsin,pdfout), require("python") gsmodule = python.import([><])","\\\%1testgs") ghost = gsmodule.gs() ghost. appendargs('-q') "\|width:" ghost.appendargs('-dNOPAUSE') ghost. tostringappendargs(head'-dEPSCrop') ghost.widthappendargs('-sDEVICE=pdfwrite') ghost.. InFile = epsin "\|depth:" ghost.OutFile = pdfout ghost. tostringrun()end function barcode(head.depthtext,type,options,savefile) .. require("\|height:python" ) gsmodule = python.. tostringimport(head.height"testgs")   barcode_string = string.. format("%%!\|dir:" .. tostringn100 100 moveto (head.dir%s) (%s) %s barcode showpage" ,text,options,type) .. "\|next:" .. psfile = string.gsubformat(tostring(head"%s.nextps",savefile)," epsfile = string.format([><])","\\\%1s.eps",savefile) pdffile = string.format("%s. pdf"\|prev,savefile)  temp = io.open(psfile,'w') temp:" .. string.gsubwrite(tostring(head.prevbarcode_string),"\n") temp:flush([><])","\\\%1")) end if id io.close(temp) ghost == nodegsmodule.idgs("ins") then k = k + 1 nd[n] = gv ghost.rawappendargs('-q') ghost.noderawappendargs(g,ndlbl'-dNOPAUSE') res = gv ghost.setvrawappendargs(nd[n]'-sDEVICE=epswrite') ghost.rawappendargs(string.format('-sOutputFile=%s',"shape","record"epsfile)) res = gv ghost.setvrawappendargs(nd[n],"label",tostring(k'barcode.ps') ghost.InFile= psfile ghost. " " .. "ins" .. run()end "\|id:stopluacode \def\epstopdf#1#2{\ctxlua{epstopdf("#1","#2" .. tostring(head.id) .. }} "\|subtype:" def\EPSfigure[#1]{%lazy way to load eps\epstopdf{#1.eps}{#1. tostring(head.subtype) .pdf}%\externalfigure[#1. pdf]%}  "\|attr:" .. string.gsub(tostring(head.attr),"(def\PutBarcode[><#1])","{%\\\%getparameters[bc][#1") .. ]% \ctxlua{barcode("\|cost:csname bctext\endcsname" .. tostring(head.cost) .. ,"\|depth:csname bctype\endcsname" .. tostring(head.depth) .. ,"\|height:csname bcoptions\endcsname" .. tostring(head.height) .. ,"\|spec:csname bcsavefile\endcsname" .. string.gsub(tostring(head.spec),"(}%\expanded{\EPSfigure[><])","\\csname bcsavefile\endcsname]}%1") .. "} \starttext\startTEXpage\|list:" .. string.gsub(tostring(head.list),"(startcombination[><2*2]{\PutBarcode[text={CODE 39},type={code39},options={includecheck includetext},savefile={TEMP1}])","}{\ss code39}{\PutBarcode[text={CONTEXT},type={code93},options={includecheck includetext},savefile={TEMP2}]}{\%1") .. ss code93} "{\|next:" .. string.gsub(tostring(head.next),"(PutBarcode[><])"text={977147396801},"type={ean13},options={includetext},savefile={TEMP3}]}{\ss ean13}{\PutBarcode[text={0123456789},type={interleaved2of5},options={includecheck includetext},savefile={TEMP4}]}{\ss interleaved2of5}\%1") .. stopcombination "\|prevstopTEXpage\stoptext</texcode> [[Image:" Test-ghostscript-barcode.png|900px]] == Graphviz == [http://www.graphviz. stringorg Graphviz] is a Graph Visualization Software .gsub<br/>Standard distribution comes with several binding (tostring(headlua and python among others) so it's not difficult to integrate in luatex lunatic .prev)<br/>In this example,"([we draw a graph of the nodes of <context>\TeX<])","/context><pre>\def\StudyBox#1{%\%1startluacoderequire "python")) end if id gv == nodepython.idimport("markgv") then k = k + 1 nd[n] g = gv.nodedigraph(g,ndlbl"G") res = gv.setv(nd[n]g,"shape"'rankdir',"record"'LR') res nodes = gv.setv(nodes or {} local nd[= {};local kd = {}; local k = 0;local function nodesprint(head,n],"label",tostring(k) while head do local id = head.id local oldn = n ndlbl = string. format(" nd_\%03d" ,k) texio.write_nl(string. format("mark" .. "id=\|id:%s, ndlbl=\%s" .. tostring(head.,id,ndlbl))   if id == node.. id("\|subtype:vlist" .. tostring(head.subtype) .. then k = k + 1 "\|attr:" nd[n] = gv.. string.gsubnode(tostring(headg,ndlbl) res = gv.attr),"setv(nd[><n]),"shape","\\\%1record") .. "\|class:" res = gv.. tostringsetv(headnd[n],"label",tostring(k) .class) . " " .. "vlist" .. "\|markid:" .. tostring(head.markid) .. "\|nextsubtype:" .. string.gsub(tostring(head.next),"([><])","\\\%1"subtype) .. "\|prevattr:" .. string.gsub(tostring(head.prevattr),"([><])","\\\%1")).. end if id == node "\|width:" ..idtostring("adjust"head.width) then.. k = k + 1 nd[n] = gv "\|depth:" ..nodetostring(g,ndlblhead.depth) res = gv.setv. "\|height:" .. tostring(nd[n],"shape","record"head.height).. res = gv "\|dir:" ..setv(nd[n],"label",tostring(khead.dir) .. " \|shift:" .. "adjust" tostring(head.shift) .. "\|idglue_order:" .. tostring(head.glue_order) .. "\|glue_sign:" .. tostring(head.idglue_sign) .. "\|subtypeglue_set:" .. tostring(head.subtypeglue_set) .. "\|attrlist:" .. string.gsub(tostring(head.attrlist),"([><])","\\\%1") .. "\|listprev:" .. string.gsub(tostring(head.listprev),"([><])","\\\%1") .. "\|prevnext:" .. string.gsub(tostring(head.prevnext),"([><])","\\\%1") ) end  if id == node.. id("\|next:rule" ) then k = k + 1 nd[n] = gv.. string.gsubnode(tostring(head.nextg,ndlbl)," res = gv.setv(nd[><n]),"shape","\\\%1record")) end if id == node.id("disc") then k = k + 1 nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record") res = gv.setv(nd[n],"label",tostring(k) .. " " .. "disc" .. "\|id:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) .. "\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") .. "\|pre:" .. string.gsub(tostring(head.pre),"([><])","\\\%1") .. "\|post:" .. string.gsub(tostring(head.post),"([><])","\\\%1") .. "\|replace:" .. string.gsub(tostring(head.replace),"([><])","\\\%1") .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1")) end if id == node.id("whatsit") then k = k + 1 nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record") if head.subtype == node.subtype("write") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:write" .. "\|id:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) .. "\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") .. "\|stream:" .. tostring(head.stream) .. "\|data:" .. tostring(head.data) .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1")) end if head.subtype == node.subtype("close") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:close" .. "\|id:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) .. "\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") .. "\|stream:" .. tostring(head.stream) .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1")) end if head.subtype == node.subtype("special") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:special" .. "\|id:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) .. "\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") .. "\|data:" .. tostring(head.data) .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1")) end if head.subtype == node.subtype("local_par") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:local_par" .. "\|id:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) .. "\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") .. "\|pen_inter:" .. tostring(head.pen_inter) .. "\|pen_broken:" .. tostring(head.pen_broken) .. "\|dir:" .. tostring(head.dir) .. "\|box_left:" .. tostring(head.box_left) .. "\|box_left_width:" .. tostring(head.box_left_width) .. "\|box_right:" .. tostring(head.box_right) .. "\|box_right_width:" .. tostring(head.box_right_width) .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1")) end if head.subtype == node.subtype("dir") then res = gv res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:dirrule" .. "\|id:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|width:" .. tostring(head.width) ..
"\|depth:" .. tostring(head.depth) ..
"\|height:" .. tostring(head.height) ..
"\|dir:" .. tostring(head.dir) ..
"\|level:" .. tostring(head.level) ..
"\|dvi_ptr:" .. tostring(head.dvi_ptr) ..
"\|dvi_h:" .. tostring(head.dvi_h) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end if headid == node.subtype id("ins") then k =k + 1 nd[n] = gv.node(g,ndlbl) res = gv.subtypesetv(nd[n],"shape"pdf_literal,"record") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_literalins" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|modecost:" .. tostring(head.modecost) .. "\|datadepth:" .. tostring(head.datadepth) .. "\|height:" .. tostring(head.height) .. "\|spec:" .. string.gsub(tostring(head.spec),"([><])","\\\%1") .. "\|list:" .. string.gsub(tostring(head.list),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end if headid == node.subtype id("mark") then k =k + 1 nd[n] = gv.node(g,ndlbl) res = gv.subtypesetv(nd[n],"shape"pdf_refobj,"record") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_refobjmark" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|objnumclass:" .. tostring(head.objnumclass) .. "\|mark:" .. tostring(head.mark) .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1")) end if id == node.id("adjust") then k = k + 1 nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record") res = gv.setv(nd[n],"label",tostring(k) .. " " .. "adjust" .. "\|id:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) .. "\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") .. "\|list:" .. string.gsub(tostring(head.list),"([><])","\\\%1") .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end if headid == node.subtype id("disc") then k =k + 1 nd[n] = gv.node(g,ndlbl) res = gv.subtypesetv(nd[n],"pdf_refxformshape","record") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_refxformdisc" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|widthpre:" .. string.gsub(tostring(head.widthpre),"([><])","\\\%1") .. "\|heightpost:" .. string.gsub(tostring(head.heightpost),"([><])","\\\%1") .. "\|depthreplace:" .. string.gsub(tostring(head.depthreplace) .. ,"([><])","\|objnum:\\%1" .. tostring(head.objnum) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end if head.subtype id == node.subtypeid("pdf_refximagewhatsit") then res k = gv.setv(k + 1 nd[n],"label",tostring(k) = gv.. " " .."whatsit:pdf_refximage" .. "\|id:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) .. "\|attr:" .. string.gsubnode(tostring(head.attr)g,"([><])","\\\%1"ndlbl) res = gv.. "\|width:" .. tostring(head.width) .. "\|height:" .. tostring(head.height) .. "\|depth:" .. tostring(head.depth) .. "\|objnum:" .. tostring(head.objnum) .. "\|next:" .. string.gsub(tostring(head.next),"setv(nd[><n])","\\\%1") .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])shape","\\\%1record")) end if head.subtype == node.subtype("pdf_annotwrite") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_annotwrite" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|widthstream:" .. tostring(head.width) .. "\|height:" .. tostring(head.height) .. "\|depth:" .. tostring(head.depth) .. "\|objnum:" .. tostring(head.objnumstream) ..
"\|data:" .. tostring(head.data) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if head.subtype == node.subtype("pdf_start_linkclose") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_start_linkclose" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|widthstream:" .. tostring(head.width) .. "\|height:" .. tostring(head.height) .. "\|depth:" .. tostring(head.depth) .. "\|objnum:" .. tostring(head.objnum) .. "\|link_attr:" .. tostring(head.link_attr) .. "\|action:" .. tostring(head.actionstream) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if head.subtype == node.subtype("pdf_end_linkspecial") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_end_linkspecial" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|data:" .. tostring(head.data) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if head.subtype == node.subtype("pdf_destlocal_par") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_destlocal_par" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|widthpen_inter:" .. tostring(head.widthpen_inter) .. "\|heightpen_broken:" .. tostring(head.heightpen_broken) .. "\|depthdir:" .. tostring(head.depthdir) .. "\|named_idbox_left:" .. tostring(head.named_idbox_left) .. "\|dest_idbox_left_width:" .. tostring(head.dest_idbox_left_width) .. "\|dest_typebox_right:" .. tostring(head.dest_typebox_right) .. "\|xyz_zoombox_right_width:" .. tostring(head.xyz_zoom) .. "\|objnum:" .. tostring(head.objnumbox_right_width) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if head.subtype == node.subtype("pdf_threaddir") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_threaddir" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|widthdir:" .. tostring(head.widthdir) .. "\|heightlevel:" .. tostring(head.heightlevel) .. "\|depthdvi_ptr:" .. tostring(head.depthdvi_ptr) .. "\|named_iddvi_h:" .. tostring(head.named_iddvi_h) .. "\|thread_id:" .. tostring(head.thread_id) .. "\|thread_attr:" .. tostring(head.thread_attr) .. "\|prevnext:" .. string.gsub(tostring(head.prevnext),"([><])","\\\%1") .. "\|nextprev:" .. string.gsub(tostring(head.nextprev),"([><])","\\\%1"))
end
if head.subtype == node.subtype("pdf_start_threadpdf_literal") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_start_threadpdf_literal" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|widthmode:" .. tostring(head.widthmode) .. "\|heightdata:" .. tostring(head.heightdata) .. "\|depth:" .. tostring(head.depth) .. "\|named_id:" .. tostring(head.named_id) .. "\|thread_id:" .. tostring(head.thread_id) .. "\|thread_attr:" .. tostring(head.thread_attr) .. "\|prevnext:" .. string.gsub(tostring(head.prevnext),"([><])","\\\%1") .. "\|nextprev:" .. string.gsub(tostring(head.nextprev),"([><])","\\\%1"))
end
if head.subtype == node.subtype("pdf_end_threadpdf_refobj") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_end_threadpdf_refobj" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|objnum:" .. tostring(head.objnum) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if head.subtype == node.subtype("pdf_save_pospdf_refxform") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_save_pospdf_refxform" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|prevwidth:" .. tostring(head.width) .. "\|height:" .. tostring(head.height) .. "\|depth:" .. tostring(head.depth) .. "\|objnum:" .. tostring(head.objnum) .. "\|next:" .. string.gsub(tostring(head.prevnext),"([><])","\\\%1") .. "\|nextprev:" .. string.gsub(tostring(head.nextprev),"([><])","\\\%1"))
end
if head.subtype == node.subtype("pdf_thread_datapdf_refximage") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_thread_datapdf_refximage" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") .. "\|width:" .. tostring(head.width) .. "\|height:" .. tostring(head.height) .. "\|depth:" .. tostring(head.depth) .. "\|objnum:" .. tostring(head.objnum) .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if head.subtype == node.subtype("pdf_link_datapdf_annot") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_link_data" .. "\|id:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1")) end if head.subtype == node.subtype("open") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:openpdf_annot" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|streamwidth:" .. tostring(head.streamwidth) .. "\|nameheight:" .. tostring(head.nameheight) .. "\|areadepth:" .. tostring(head.areadepth) .. "\|extobjnum:" .. tostring(head.extobjnum) .. "\|data:" .. tostring(head.data) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if head.subtype == node.subtype("late_luapdf_start_link") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:late_luapdf_start_link" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|regwidth:" .. tostring(head.regwidth) .. "\|dataheight:" .. tostring(head.dataheight) .. "\|namedepth:" .. tostring(head.namedepth) .. "\|nextobjnum:" .. tostring(head.objnum) .. "\|link_attr:" .. tostring(head.link_attr) .. "\|action:" .. tostring(head.action) .. "\|prev:" .. string.gsub(tostring(head.nextprev),"([><])","\\\%1") .. "\|prevnext:" .. string.gsub(tostring(head.prevnext),"([><])","\\\%1"))
end
if head.subtype == node.subtype("fakepdf_end_link") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:fakepdf_end_link" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if head.subtype == node.subtype("pdf_colorstackpdf_dest") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_colorstackpdf_dest" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|stackwidth:" .. tostring(head.stackwidth) .. "\|cmdheight:" .. tostring(head.cmdheight) .. "\|datadepth:" .. tostring(head.datadepth) .. "\|nextnamed_id:" .. tostring(head.named_id) .. "\|dest_id:" .. tostring(head.dest_id) .. "\|dest_type:" .. tostring(head.dest_type) .. "\|xyz_zoom:" .. tostring(head.xyz_zoom) .. "\|objnum:" .. tostring(head.objnum) .. "\|prev:" .. string.gsub(tostring(head.nextprev),"([><])","\\\%1") .. "\|prevnext:" .. string.gsub(tostring(head.prevnext),"([><])","\\\%1"))
end
if head.subtype == node.subtype("pdf_savepdf_thread") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_savepdf_thread" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|width:" .. tostring(head.width) ..
"\|height:" .. tostring(head.height) ..
"\|depth:" .. tostring(head.depth) ..
"\|named_id:" .. tostring(head.named_id) ..
"\|thread_id:" .. tostring(head.thread_id) ..
"\|thread_attr:" .. tostring(head.thread_attr) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if head.subtype == node.subtype("cancel_boundarypdf_start_thread") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:cancel_boundarypdf_start_thread" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|width:" .. tostring(head.width) ..
"\|height:" .. tostring(head.height) ..
"\|depth:" .. tostring(head.depth) ..
"\|named_id:" .. tostring(head.named_id) ..
"\|thread_id:" .. tostring(head.thread_id) ..
"\|thread_attr:" .. tostring(head.thread_attr) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if head.subtype == node.subtype("close_luapdf_end_thread") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:close_luapdf_end_thread" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|reg:" .. tostring(head.reg) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if head.subtype == node.subtype("pdf_setmatrixpdf_save_pos") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_setmatrixpdf_save_pos" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|data:" .. tostring(head.data) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if head.subtype == node.subtype("pdf_restorepdf_thread_data") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_restorepdf_thread_data" .. "\|id:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1")) end if head.subtype == node.subtype("pdf_link_data") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:pdf_link_data" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if head.subtype == node.subtype("user_definedopen") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:user_definedopen" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|user_idstream:" .. tostring(head.user_idstream) .. "\|typename:" .. tostring(head.typename) .. "\|valuearea:" .. tostring(head.valuearea) .. "\|ext:" .. tostring(head.ext) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
end if id head.subtype == node.idsubtype("mathlate_lua") then k = k + 1 nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record") res = gv.setv(nd[n],"label",tostring(k) .. " " .. "mathwhatsit:late_lua" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|surroundreg:" .. tostring(head.surroundreg) .. "\|data:" .. tostring(head.data) .. "\|name:" .. tostring(head.name) .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1")) end if head.subtype == node.subtype("fake") then res = gv.setv(nd[n],"label",tostring(k) .. " " .."whatsit:fake" .. "\|id:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end if id head.subtype == node.idsubtype("gluepdf_colorstack") then k = k + 1 nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record") res = gv.setv(nd[n],"label",tostring(k) .. " " .. "gluewhatsit:pdf_colorstack" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|specstack:" .. string.gsub(tostring(head.specstack),"([><])",.. "\\\%1|cmd:".. tostring(head.cmd) .. "\|leaderdata:" .. tostring(head.leaderdata) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end if id head.subtype == node.idsubtype("kernpdf_save") then k = k + 1 nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record") res = gv.setv(nd[n],"label",tostring(k) .. " " .. "kernwhatsit:pdf_save" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|kern:" .. tostring(head.kern) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end if id head.subtype == node.idsubtype("penaltycancel_boundary") then k = k + 1 nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record") res = gv.setv(nd[n],"label",tostring(k) .. " " .. "penaltywhatsit:cancel_boundary" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|penalty:" .. tostring(head.penalty) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end if id head.subtype == node.idsubtype("unsetclose_lua") then k = k + 1 nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record") res = gv.setv(nd[n],"label",tostring(k) .. " " .. "unsetwhatsit:close_lua" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|widthreg:" .. tostring(head.widthreg) .. "\|depthprev:" .. string.gsub(tostring(head.depthprev),"([><]) .. ","\|height:\\%1" .. tostring(head.height) .. "\|dirnext:" .. string.gsub(tostring(head.dirnext),"([><]) .. ","\|shrink:\\%1" )) end if head.subtype == node. tostringsubtype(head.shrink"pdf_setmatrix") then res = gv.. setv(nd[n],"\|glue_order:label" .. ,tostring(head.glue_orderk) .. "\|glue_sign:" .. tostring(head.glue_sign) "whatsit:pdf_setmatrix" .. "\|stretchid:" .. tostring(head.stretchid) .. "\|spansubtype:" .. tostring(head.spansubtype) .. "\|listattr:" .. string.gsub(tostring(head.listattr),"([><])","\\\%1") .. "\|data:" .. tostring(head.data) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end if id head.subtype == node.idsubtype("stylepdf_restore") then k = k + 1 nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record") res = gv.setv(nd[n],"label",tostring(k) .. " " .. "stylewhatsit:pdf_restore" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|style:" .. tostring(head.style) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end if id head.subtype == node.idsubtype("choiceuser_defined") then k = k + 1 nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record") res = gv.setv(nd[n],"label",tostring(k) .. " " .. "choicewhatsit:user_defined" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|displayuser_id:" .. tostring(head.displayuser_id) .. "\|texttype:" .. tostring(head.texttype) .. "\|scriptvalue:" .. tostring(head.script) .. "\|scriptscript:" .. tostring(head.scriptscriptvalue) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
end
if id == node.id("noadmath") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "noadmath" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|nucleussurround:" .. tostring(head.nucleussurround) .. "\|sub:" .. tostring(head.sub) .. "\|sup:" .. tostring(head.sup) .. "\|nextprev:" .. string.gsub(tostring(head.nextprev),"([><])","\\\%1") .. "\|prevnext:" .. string.gsub(tostring(head.prevnext),"([><])","\\\%1"))
end
if id == node.id("opglue") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "opglue" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|nucleusspec:" .. string.gsub(tostring(head.nucleusspec),"([><]) .. ","\\|sub:\%1" .. tostring(head.sub) .. "\|supleader:" .. tostring(head.supleader) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("binkern") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "binkern" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|nucleuskern:" .. tostring(head.nucleuskern) .. "\|sub:" .. tostring(head.sub) .. "\|sup:" .. tostring(head.sup) .. "\|nextprev:" .. string.gsub(tostring(head.nextprev),"([><])","\\\%1") .. "\|prevnext:" .. string.gsub(tostring(head.prevnext),"([><])","\\\%1"))
end
if id == node.id("relpenalty") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "relpenalty" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|nucleuspenalty:" .. tostring(head.nucleuspenalty) .. "\|sub:" .. tostring(head.sub) .. "\|sup:" .. tostring(head.sup) .. "\|nextprev:" .. string.gsub(tostring(head.nextprev),"([><])","\\\%1") .. "\|prevnext:" .. string.gsub(tostring(head.prevnext),"([><])","\\\%1"))
end
if id == node.id("openunset") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "openunset" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|nucleuswidth:" .. tostring(head.nucleuswidth) .. "\|subdepth:" .. tostring(head.subdepth) .. "\|supheight:" .. tostring(head.supheight) .. "\|nextdir:" .. tostring(head.dir) .. "\|shrink:" .. tostring(head.shrink) .. "\|glue_order:" .. tostring(head.glue_order) .. "\|glue_sign:" .. tostring(head.glue_sign) .. "\|stretch:" .. tostring(head.stretch) .. "\|span:" .. tostring(head.span) .. "\|list:" .. string.gsub(tostring(head.nextlist),"([><])","\\\%1") .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1")) end if id == node.id("closestyle") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "closestyle" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|nucleusstyle:" .. tostring(head.nucleusstyle) .. "\|sub:" .. tostring(head.sub) .. "\|sup:" .. tostring(head.sup) .. "\|nextprev:" .. string.gsub(tostring(head.nextprev),"([><])","\\\%1") .. "\|prevnext:" .. string.gsub(tostring(head.prevnext),"([><])","\\\%1"))
end
if id == node.id("punctchoice") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "punctchoice" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|nucleusdisplay:" .. tostring(head.nucleusdisplay) .. "\|subtext:" .. tostring(head.subtext) .. "\|supscript:" .. tostring(head.supscript) .. "\|scriptscript:" .. tostring(head.scriptscript) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("innernoad") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "innernoad" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("radicalop") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "radicalop" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|sub:" .. tostring(head.sub) ..
"\|sup:" .. tostring(head.sup) ..
"\|left:" .. tostring(head.left) ..
"\|degree:" .. tostring(head.degree) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("fractionbin") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "fractionbin" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|widthnucleus:" .. tostring(head.widthnucleus) .. "\|numsub:" .. tostring(head.numsub) .. "\|denomsup:" .. tostring(head.denom) .. "\|left:" .. tostring(head.left) .. "\|right:" .. tostring(head.rightsup) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("underrel") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "underrel" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("overopen") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "overopen" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("accentclose") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "accentclose" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|sub:" .. tostring(head.sub) ..
"\|sup:" .. tostring(head.sup) ..
"\|accent:" .. tostring(head.accent) ..
"\|bot_accent:" .. tostring(head.bot_accent) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("vcenterpunct") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "vcenterpunct" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("fenceinner") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "fenceinner" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|delimnucleus:" .. tostring(head.delimnucleus) .. "\|prevsub:" .. tostring(head.sub) .. "\|sup:" .. tostring(head.sup) .. "\|next:" .. string.gsub(tostring(head.prevnext),"([><])","\\\%1") .. "\|nextprev:" .. string.gsub(tostring(head.nextprev),"([><])","\\\%1"))
end
if id == node.id("math_charradical") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "math_charradical" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|famnucleus:" .. tostring(head.famnucleus) .. "\|charsub:" .. tostring(head.charsub) .. "\|sup:" .. tostring(head.sup) .. "\|left:" .. tostring(head.left) .. "\|degree:" .. tostring(head.degree) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("sub_boxfraction") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "sub_boxfraction" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|listwidth:" .. stringtostring(head.width) .. "\|num:" ..gsubtostring(head.num) .. "\|denom:" .. tostring(head.listdenom),.. "\|left:".. tostring([><]head.left)",.. "\\\%1|right:".. tostring(head.right) .. "\|prevnext:" .. string.gsub(tostring(head.prevnext),"([><])","\\\%1") .. "\|nextprev:" .. string.gsub(tostring(head.nextprev),"([><])","\\\%1"))
end
if id == node.id("sub_mlistunder") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "sub_mlistunder" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|listnucleus:" .. string.gsub(tostring(head.listnucleus),.. "\|sub:".. tostring([><]head.sub)",.. "\\\%1|sup:".. tostring(head.sup) .. "\|prevnext:" .. string.gsub(tostring(head.prevnext),"([><])","\\\%1") .. "\|nextprev:" .. string.gsub(tostring(head.nextprev),"([><])","\\\%1"))
end
if id == node.id("math_text_charover") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "math_text_charover" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|famnucleus:" .. tostring(head.famnucleus) .. "\|charsub:" .. tostring(head.charsub) .. "\|sup:" .. tostring(head.sup) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("delimaccent") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "delimaccent" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|small_famnucleus:" .. tostring(head.small_famnucleus) .. "\|small_charsub:" .. tostring(head.small_charsub) .. "\|large_famsup:" .. tostring(head.large_famsup) .. "\|large_characcent:" .. tostring(head.large_characcent) .. "\|bot_accent:" .. tostring(head.bot_accent) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("margin_kernvcenter") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "margin_kernvcenter" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|widthnucleus:" .. tostring(head.widthnucleus) .. "\|glyphsub:" .. tostring(head.glyphsub) .. "\|sup:" .. tostring(head.sup) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("glyphfence") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "glyphfence" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|chardelim:" .. tostring(head.char) .. "\|font:" .. tostring(head.font) .. "\|lang:" .. tostring(head.lang) .. "\|left:" .. tostring(head.left) .. "\|right:" .. tostring(head.right) .. "\|uchyph:" .. tostring(head.uchyph) .. "\|components:" .. string.gsub(tostring(head.components),"([><])","\\\%1") .. "\|xoffset:" .. tostring(head.xoffset) .. "\|yoffset:" .. tostring(head.yoffsetdelim) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if id == node.id("align_recordmath_char") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "align_recordmath_char" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") .. "\|fam:" .. tostring(head.fam) .. "\|char:" .. tostring(head.char) .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("pseudo_filesub_box") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "pseudo_filesub_box" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|list:" .. string.gsub(tostring(head.list),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if id == node.id("pseudo_linesub_mlist") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "pseudo_linesub_mlist" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|list:" .. string.gsub(tostring(head.list),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if id == node.id("page_insertmath_text_char") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "page_insertmath_text_char" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|heightattr:" .. string.gsub(tostring(head.heightattr),"([><])","\\\%1") .. "\|last_ins_ptrfam:" .. tostring(head.last_ins_ptrfam) .. "\|best_ins_ptrchar:" .. tostring(head.best_ins_ptrchar) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("split_insertdelim") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "split_insertdelim" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|heightattr:" .. string.gsub(tostring(head.heightattr),"([><])","\\\%1") .. "\|last_ins_ptrsmall_fam:" .. tostring(head.last_ins_ptrsmall_fam) .. "\|best_ins_ptrsmall_char:" .. tostring(head.best_ins_ptrsmall_char) .. "\|broken_ptrlarge_fam:" .. tostring(head.broken_ptrlarge_fam) .. "\|broken_inslarge_char:" .. tostring(head.broken_inslarge_char) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("expr_stackmargin_kern") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "expr_stackmargin_kern" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") .. "\|width:" .. tostring(head.width) .. "\|glyph:" .. tostring(head.glyph) .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("nested_listglyph") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "nested_listglyph" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") .. "\|char:" .. tostring(head.char) .. "\|font:" .. tostring(head.font) .. "\|lang:" .. tostring(head.lang) .. "\|left:" .. tostring(head.left) .. "\|right:" .. tostring(head.right) .. "\|uchyph:" .. tostring(head.uchyph) .. "\|components:" .. string.gsub(tostring(head.components),"([><])","\\\%1") .. "\|xoffset:" .. tostring(head.xoffset) .. "\|yoffset:" .. tostring(head.yoffset) .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1")) end if id == node.id("spanalign_record") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "spanalign_record" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if id == node.id("attributepseudo_file") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "attributepseudo_file" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|number:" .. tostring(head.number) ..
"\|value:" .. tostring(head.value) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if id == node.id("glue_specpseudo_line") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "glue_specpseudo_line" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|width:" .. tostring(head.width) .. "\|stretch:" .. tostring(head.stretch) .. "\|shrink:" .. tostring(head.shrink) .. "\|stretch_order:" .. tostring(head.stretch_order) .. "\|shrink_order:" .. tostring(head.shrink_order) .. "\|ref_count:" .. tostring(head.ref_count) .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("attribute_listpage_insert") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "attribute_listpage_insert" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|height:" .. tostring(head.height) ..
"\|last_ins_ptr:" .. tostring(head.last_ins_ptr) ..
"\|best_ins_ptr:" .. tostring(head.best_ins_ptr) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("actionsplit_insert") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "actionsplit_insert" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|action_typeheight:" .. tostring(head.action_typeheight) .. "\|named_idlast_ins_ptr:" .. tostring(head.named_idlast_ins_ptr) .. "\|action_idbest_ins_ptr:" .. tostring(head.action_idbest_ins_ptr) .. "\|filebroken_ptr:" .. tostring(head.filebroken_ptr) .. "\|new_windowbroken_ins:" .. tostring(head.new_windowbroken_ins) .. "\|data:" .. tostring(head.data) .. "\|ref_count:" .. tostring(head.ref_count) .. "\|prevnext:" .. string.gsub(tostring(head.prevnext),"([><])","\\\%1") .. "\|nextprev:" .. string.gsub(tostring(head.nextprev),"([><])","\\\%1"))
end
if id == node.id("tempexpr_stack") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "tempexpr_stack" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if id == node.id("align_stacknested_list") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "align_stacknested_list" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if id == node.id("movement_stackspan") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "movement_stackspan" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if id == node.id("if_stackattribute") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "if_stackattribute" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|number:" .. tostring(head.number) ..
"\|value:" .. tostring(head.value) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if id == node.id("unhyphenatedglue_spec") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "unhyphenatedglue_spec" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|width:" .. tostring(head.width) .. "\|stretch:" .. tostring(head.stretch) .. "\|shrink:" .. tostring(head.shrink) .. "\|stretch_order:" .. tostring(head.stretch_order) .. "\|shrink_order:" .. tostring(head.shrink_order) .. "\|ref_count:" .. tostring(head.ref_count) .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("hyphenatedattribute_list") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "hyphenatedattribute_list" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1") .. "\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1"))
end
if id == node.id("deltaaction") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "deltaaction" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|action_type:" .. tostring(head.action_type) ..
"\|named_id:" .. tostring(head.named_id) ..
"\|action_id:" .. tostring(head.action_id) ..
"\|file:" .. tostring(head.file) ..
"\|new_window:" .. tostring(head.new_window) ..
"\|data:" .. tostring(head.data) ..
"\|ref_count:" .. tostring(head.ref_count) ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if id == node.id("passivetemp") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "passivetemp" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if id == node.id("shapealign_stack") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "shapealign_stack" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if id == node.id("hlistmovement_stack") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record")
res = gv.setv(nd[n],"label",tostring(k) .. " " .. "hlistmovement_stack" .. "\|id:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1")) end if id == node.id("if_stack") then k = k + 1 nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record") res = gv.setv(nd[n],"label",tostring(k) .. " " .. "if_stack" .. "\|id:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) .. "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1")) end if id == node.id("unhyphenated") then k = k + 1 nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record") res = gv.setv(nd[n],"label",tostring(k) .. " " .. "unhyphenated" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|attr:" .. string.gsub(tostring(head.attr),"([><])","\\\%1") ..
"\|width:" .. tostring(head.width) ..
"\|depth:" .. tostring(head.depth) ..
"\|height:" .. tostring(head.height) ..
"\|dir:" .. tostring(head.dir) ..
"\|shift:" .. tostring(head.shift) ..
"\|glue_order:" .. tostring(head.glue_order) ..
"\|glue_sign:" .. tostring(head.glue_sign) ..
"\|glue_set:" .. tostring(head.glue_set) ..
"\|list:" .. string.gsub(tostring(head.list),"([><])","\\\%1") ..
"\|prev:" .. string.gsub(tostring(head.prev),"([><])","\\\%1") ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
if id == node.id("fakehyphenated") then
k = k + 1
nd[n] = gv.node(g,ndlbl) res = gv.setv(nd[n],"shape","record") res = gv.setv(nd[n],"label",tostring(k) .. " " .. "fakehyphenated" ..
"\|id:" .. tostring(head.id) ..
"\|subtype:" .. tostring(head.subtype) ..
"\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
kd if id == node.id("delta") then k = k + 1 nd[kn] = gv.node(g,ndlbl) res = gv.setv(nd[n] ,"shape","record") e1 res = gv.edgesetv(kdnd[k-1n],kd["label",tostring(k]).. " " .. "delta" .. if "\|id == node:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) .. "\|next:" .. string.gsub(tostring('hlist'head.next) or ,"([><])","\\\%1")) end if id == node.id('vlist'"passive") then %% If we want to connect nested k = k + 1 nd[n] = gv.node(h|vg,ndlbl)list %% %%e res = gv.edgesetv(nd[n-1],nd[n]"shape","record") %% res = gv.setv(end[n],'arrowhead'"label",'diamond'tostring(k).. " " .. "passive" .. nodesprint "\|id:" .. tostring(head.list,id) .. "\|subtype:" .. tostring( n or 0) +1head.subtype).. end head = "\|next:" .. string.gsub(tostring(head.next),"([><])","\\\%1"))
end
end if id == node.id("shape") then k = k + 1local head nd[n] = gv.node(g,ndlbl) res = texgv.boxsetv(nd[#1n],"shape","record")nodesprint res = gv.setv(nd[n],"label",tostring(k) .. " " .. "shape" .. "\|id:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) .. "\|next:" .. string.gsub(tostring(head.next),0"([><])","\\\%1")) end if id == node.id("hlist")thenr k = k + 1 nd[n] = gv.layoutnode(g,ndlbl) res = gv.setv(nd[n],"dotshape","record")r res = gv.rendersetv(gnd[n],'pdf'"label",tostring(k) .. " " .. "hlist" .. "\|id:" .. tostring(head.id) .. "\|subtype:" .. tostring(head.subtype) .. "\|attr:" .. string.formatgsub('boxtostring(head.attr),"([><])","\\\%d.pdf',#1").. "\|width:" .. tostring(head.width).. "\stopluacode%%|depth:" .. tostring(head.depth) .. } "\|height:" .. tostring(head.height) .. "\|dir:" .. tostring(head.dir) .. "\starttext|shift:" .. tostring(head.shift) .. "\startTEXpage|glue_order:" .. tostring(head.glue_order) .. "\setbox0=|glue_sign:" .. tostring(head.glue_sign) .. "\hbox{\TeX}|glue_set:" .. tostring(head.glue_set) .. "\hbox to 29cm{\strut|list:" .. string.gsub(tostring(head.list),"([><])","\hss\copy0\hss}\StudyBox{0}%1") .. "\externalfigure[box0|prev:" .. string.gsub(tostring(head.pdf]prev),"([width=29cm><])","\\\stopTEXpage%1") .. "\stoptext</pre>[[Image|next:Graphviz" .. string.gsub(tostring(head.png|900px]next),"([><])","\\\%1")) end if id ==node.id("fake") then k = R k + 1 nd[n] =gv.node(g,ndlbl) res =gv.setv(nd[n],"shape","record")R is a language and environment for statistical computing and graphics res = gv.setv(nd[httpn],"label",tostring(k) .. " " .. "fake" .. "\|id://www" .r-project.org tostring(see herehead.id)] . <br/>. RPy is a very simple, yet robust, Python interface to the R Programming Language [http "\|subtype://rpy" .sourceforge.net tostring(see herehead.subtype)] . . "\|next:" .. string.gsub(tostring(head.next),"([><br/>])","\\\%1")) end kd[k] = nd[n] As example e1 = gv.edge(kd[k-1], letkd[k]) if id == node.id('hlist's try ) or id == node.id('vlist') then %% If we want to plot a discrete distribution of probability for a set of pseudorandom number connect nested (around 100000 samplesh|v) list %% %%e = gv.edge(nd[n-1],nd[n])<pre> %%gv.setv(e,'arrowhead','diamond')import rpy2 nodesprint(head.robjects as robjectslist,( n or 0) +1)import rpy2 end head = head.rinterface as rinterfacenext endclass density(object):end
local head = tex.box[#1]nodesprint(head,0)r = gv.layout(g,"dot")r = gv.render(g,'pdf',string.format('box\%d.pdf',#1))\stopluacode%%} \starttext\startTEXpage\setbox0=\hbox{\TeX}\hbox to 29cm{\strut\hss\copy0\hss}\StudyBox{0}%\externalfigure[box0.pdf][width=29cm]\stopTEXpage\stoptext</pre>[[Image:Graphviz.png|900px]] == R ==R is a language and environment for statistical computing and graphics [http://www.r-project.org (see here)] . <br/>RPy is a very simple, yet robust, Python interface to the R Programming Language [http://rpy.sourceforge.net (see here)] . <br/>As example, let's try to plot a discrete distribution of probability for a set of pseudorandom number (around 100000 samples) .<pre>import rpy2.robjects as robjectsimport rpy2.rinterface as rinterface class density(object):  def __init__(self,samples,outpdf,w,h,kernel): self.samples = samples
self.outpdf= outpdf
self.kernel = kernel
As test, we can use a dump from wikiversity [http://en.wikiversity.org/wiki/Getting_stats_out_of_Wikiversity_XML_dumps (see here)] .
 
=== Build the cointainer ===
First we build the container 'Data.dbxml' in the directory "wikienv" (that must exists) :
<pre>
</pre>
The we === Make pdf ===We use this modules <tt>wikidbxml_queryTxn.py</tt>to retrive a page, given a title (it can be also used as basis to build more complex queries, but for now it's adeguate ):
<pre>
def managepara(c,res):
if c.tag == 'para' and (len(c.text.strip()) > 0is not None):
res.append(c.text.strip()+r"\par")
if c.tag == 'para' and (len(c.getchildren())>0):
res = getArtitleByTitle(title=title)
if res is not None : res = res.replace('&',r'\&') res = res.replace('#',r'\#') else: res = ''
open(filename,'wb').write( '\n'.join((preamble,res,postamble)) )
</pre>
And in the the end mkiv wrapper:
<texcode>
\usetypescriptfile[type-gentium]\usetypescript[gentium]\setupbodyfont[gentium,10pt]\setuppapersize[A5][A5]\setuplayout[height=middle,topspace=1cm,header={2\lineheight},footer=0pt,backspace=1cm,margin=1cm, width=middle]  \startluacodefunction testdbxml(title,preamble,postamble,filename) require("python") pg = python.globals() wikiversity = python.import("wikidbxml_queryTxn") wikiversity.writeres(title,preamble,postamble,filename) end\stopluacode \def\testdbxml[#1]{%\getparameters[dbxml][#1]%\ctxlua{testdbxml("\csname dbxmltitle\endcsname","\csname dbxmlpreamble\endcsname", "\csname dbxmlpostamble\endcsname","\csname dbxmlfilename\endcsname")}%\input \csname dbxmlfilename\endcsname %}   \starttext\testdbxml[title={Primary mathematics/Numbers}, preamble={}, postamble={}, filename={testres.tex}]\stoptext</texcode> Here here the result: <table class="wikitable"> <tr><td></td> <td>[[Image:Dbxml-1.png]]</td></tr><tr><td>[[Image:Dbxml-2.png]]</td> <td>[[Image:Dbxml-3.png]]</td></tr></table> One can also use sqlite that comes with python to query for titles <tt>category.db</tt>made from (for example) <tt>enwikiversity-20090627-category.sql</tt>,so reports are more simpler:just put this in python code above, right before 'if __name__' ...:<pre>import sqlite3def querycategory(title): conn = sqlite3.connect('category.db') c = conn.cursor() t = (title,) c.execute('select cat_title from category where cat_title like "%%%s%%" ;' % t) res = [row[0] for row in c] conn.commit() c.close() return res  def simplereports(title): res = querycategory(title) j = 0 for r in res: g = r.replace('_',' ') print g title= g.encode('utf8') filename = 'reps%04d.tex' % j writeres(title,'','',filename) j = j+1 return j </pre> Similary, add this to tex code<texcode>\startluacodefunction listtitles(title) require("python") pg = python.globals() wikiversity = python.import("wikidbxml_queryTxn") r = wikiversity.querycategory(title) local j = 0 local res = r[j] or {} while res do local d = string.format("\%s\\par",string.gsub(tostring(res),'_',' ')) tex.sprint(tex.ctxcatcodes,d) j = j+1 res = r[j] endend\stopluacode  \startluacodefunction simplereports(title) require("python") pg = python.globals() wikiversity = python.import("wikidbxml_queryTxn") r = wikiversity.simplereports(title) local j = tonumber(r) for v = 0,j-1 do local d = string.format("\\input reps\%04d ",v) tex.sprint(tex.ctxcatcodes,d) end print( j )end\stopluacode</texcode> and test it with  <texcode>\starttext{\bfb Query for 'geometr':}\ctxlua{listtitles("geometr")}%\ctxlua{simplereports("geometr")}%\stoptext</texcode>
 \startluacodefunction testdbxml(titlequery results are stored in reps0001.tex ,preamblereps0002.tex ,postamble,filename) require("python") pg = python.globals() wikiversity = python.import("wikidbxml_queryTxn") wikiversityand so on.writeres(title,preamble,postamble,filename) end\stopluacode   \def\testdbxml[#1]{%\getparameters[dbxml][#1]%\ctxlua{testdbxml("\csname dbxmltitle\endcsname","\csname dbxmlpreamble\endcsname", "\csname dbxmlpostamble\endcsname","\csname dbxmlfilename\endcsname")}%\input \csname dbxmlfilename\endcsname %}   \starttext\testdbxml[title={Primary mathematics/Numbers}, preamble={}, postamble={}, filename={testres.tex}]\stoptext</texcode>

Navigation menu