Re: [NTG-context] How to define a command...

2012-01-05 Thread Meer, H. van der
Reccently I did something random in ctxlua. I post it in the hope it will be useful. Hans van der Meer \startluacode -- Define our namespace as hvdm hvdm = hvdm or {} -- Return random series of numbers 1..n depending on the number of arguments function

Re: [NTG-context] How to define a command...

2012-01-05 Thread Peter Münster
On Thu, Jan 05 2012, Otared Kavian wrote: \define[3]\RandomCoeff{% \ctxlua{a = math.random(#2,#3)} % \csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not work as expected... \setuprandomize[2012] \define[3]\RandomCoeff{% \expandafter\def\csname Coeff#1

Re: [NTG-context] How to define a command...

2012-01-05 Thread Wolfgang Schuster
Am 05.01.2012 um 21:17 schrieb Peter Münster: On Thu, Jan 05 2012, Otared Kavian wrote: \define[3]\RandomCoeff{% \ctxlua{a = math.random(#2,#3)} %\csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not work as expected... \setuprandomize[2012] \define[3

Re: [NTG-context] How to define a command...

2012-01-05 Thread Wolfgang Schuster
Am 05.01.2012 um 21:11 schrieb Meer, H. van der: Reccently I did something random in ctxlua. I post it in the hope it will be useful. Hans van der Meer \startluacode -- Define our namespace as hvdm hvdm = hvdm or {} Don’t use a global namespace, you can use “userdata

Re: [NTG-context] How to define a command...

2012-01-05 Thread Otared Kavian
: Reccently I did something random in ctxlua. I post it in the hope it will be useful. Hans van der Meer \startluacode -- Define our namespace as hvdm hvdm = hvdm or {} -- Return random series of numbers 1..n depending on the number of arguments function

Re: [NTG-context] How to define a command...

2012-01-05 Thread Otared Kavian
{% \ctxlua{a = math.random(#2,#3)} %\csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not work as expected... \setuprandomize[2012] \define[3]\RandomCoeff{% \expandafter\def\csname Coeff#1\endcsname{\ctxlua{tex.print(math.random(#2,#3))}}} \starttext \RandomCoeff

Re: [NTG-context] How to define a command...

2012-01-05 Thread Otared Kavian
Thanks for Wolfgang: your solution, that is \setuprandomize[2012] \define[3]\RandomCoeff{% \setvalue{Coeff#1}{\ctxlua{tex.print(math.random(#2,#3))}}} works indeed and it is somehow simpler than using \expandafter\csname, and as a matter of fact, after reading your message I searched

Re: [NTG-context] How to define a command...

2012-01-05 Thread Otared Kavian
Hi again Wolfgang and Peter, The solution you provided to my problem is great but has a small issue… Considering the definition \define[3]\RandomCoeff{% \setvalue{Coeff#1}{\ctxlua{tex.print(math.random(#2,#3))}} } after saying \RandomCoeff{Alpha}{1}{10} one gets

Re: [NTG-context] How to define a command...

2012-01-05 Thread Otared Kavian
Sorry for the noise… I found the answer to my last question in module-01.pdf, pages 92 and 93: the right definition is \define[3]\RandomCoeff{% \setevalue{Coeff#1}{\ctxlua{tex.print(math.random(#2,#3))}} } that is one has to use \setevalue instead of \setvalue

Re: [NTG-context] redefining paragraph breaks

2012-01-03 Thread Wolfgang Schuster
= buffers.getcontent(specialparagraph) text = string.gsub(text,\n\n, ¶ ) context(text) end \stopluacode \def\startspecialparagraph {\dostartbuffer[specialparagraph][startspecialparagraph][stopspecialparagraph]} \def\stopspecialparagraph {\ctxlua{userdata.specialparagraph

[NTG-context] Broken Nightly Still

2011-12-28 Thread Kip Warner
... \dosetchemicaltext ...usestyleparameter \@cmstyle \dousecolorparameter \@cmc... \inlinechemical ...mode \hbox {\dosetchemicaltext \ctxlua {chemicals.inline(... l.39 Hydrogen is denoted

Re: [NTG-context] CLD: setupheadertexts

2011-12-26 Thread Willi Egger
\stopluacode \starttext \ctxlua{userdata.myheadertext(Right page)} \dorecurse{4}{\dontleavehmode\page} \ctxlua{userdata.myheadertext(Right page,Left page)} \dorecurse{4}{\dontleavehmode\page} \stoptext This is indeed a very good approach. I will try it! Thank you very much

Re: [NTG-context] CLD: setupheadertexts

2011-12-25 Thread Wolfgang Schuster
[realpageno]) then context(rightpage) else context(leftpage) end return true end } end \stopluacode \starttext \ctxlua

[NTG-context] CLD: setupheadertexts

2011-12-24 Thread Willi Egger
) context.setupheadertexts{ function() context.labeltext(s) context(: ) end} end \stopluacode \starttext \ctxlua{myheadertext(A)} \input knuth \page \input ward \stoptext Thanks for enlighten me! Willi

Re: [NTG-context] CLD: setupheadertexts

2011-12-24 Thread Wolfgang Schuster
true end } end \stopluacode \starttext \ctxlua{userdata.myheadertext(A)} \input knuth \page \input ward \stoptext Wolfgang ___ If your question is of interest to others as well, please add

Re: [NTG-context] CLD: setupheadertexts

2011-12-24 Thread Willi Egger
= userdata or { } function userdata.myheadertext(s) context.setupheadertexts{ function() context.labeltext(s) context(: ) return true end } end \stopluacode \starttext \ctxlua

Re: [NTG-context] Struggling with cld document...

2011-12-23 Thread Willi Egger
) end } end \stopluacode \ctxlua{documentdata.myheadertext(Headertext)} \starttext \input knuth \stoptext Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki

Re: [NTG-context] Struggling with cld document...

2011-12-22 Thread Wolfgang Schuster
) context.setupheadertexts{s} end \stopluacode \starttext \ctxluamyheadertext{Headertext}} String are passed with braces. \ctxlua{documentdata.myheadertext(Headertext)} Wolfgang ___ If your question is of interest to others as well

Re: [NTG-context] Struggling with cld document...

2011-12-22 Thread Willi Egger
) context.setupheadertexts{s} end \stopluacode \starttext \ctxluamyheadertext{Headertext}} String are passed with braces. \ctxlua{documentdata.myheadertext(Headertext)} Wolfgang ___ If your question

Re: [NTG-context] Struggling with cld document...

2011-12-22 Thread Wolfgang Schuster
) -- context.space() context(: ) context(s) end } end \stopluacode \ctxlua{documentdata.myheadertext(Headertext)} \starttext \input knuth \stoptext Wolfgang ___ If your question

Re: [NTG-context] xml attribute conditional

2011-12-14 Thread Hans Hagen
e.at.footnote = n notes[id] = n e.at[xml:id] = id end end end end \stopluacode \startxmlsetups xml:text \ctxlua{document.preprocess()} \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:div:a \par[div a]\par

[NTG-context] gnuplot module: `option=monochrome` does not work.

2011-12-13 Thread Paul Menzel
Dear ConTeXt folks, I want to create monochrome plots, but `option=monochrome` is ignored. \usemodule[gnuplot] \setupGNUPLOT[terminal=context,option=monochrome] \startGNUPLOTscript[pi] plot pi t '$π = \ctxlua{context(math.pi

[NTG-context] Lua and module gnuplot: Manipulate Gnuplot script with Lua

2011-12-12 Thread Paul Menzel
to read values from a file in Lua and just tried to print a constant to the gnuplot command. I tried the following. \usemodule[gnuplot] \startGNUPLOTscript[lua] plot \ctxlua{context(1.2 * x + 3)} \stopGNUPLOTscript \startGNUPLOTscript

Re: [NTG-context] Lua and module gnuplot: Manipulate Gnuplot script with Lua

2011-12-12 Thread Mojca Miklavec
the formula for the line for me. I have not yet figured out how to read values from a file in Lua and just tried to print a constant to the gnuplot command. I tried the following.        \usemodule[gnuplot]        \startGNUPLOTscript[lua]           plot \ctxlua{context(1.2 * x + 3

Re: [NTG-context] Lua and module gnuplot: Manipulate Gnuplot script with Lua

2011-12-12 Thread Mojca Miklavec
it) would be the following: \startGNUPLOTscript[name] plot sin(x) t '$\pi = \ctxlua{math.pi()}$' \stopGNUPLOTscript How can you explain to ConTeXt whether lua command has to be executed before or after gnuplot does its job? (label width will be wrong in either case, but that's not the point) Mojca

Re: [NTG-context] Lua and module gnuplot: Manipulate Gnuplot script with Lua

2011-12-12 Thread Hans Hagen
for the line for me. I have not yet figured out how to read values from a file in Lua and just tried to print a constant to the gnuplot command. I tried the following. \usemodule[gnuplot] \startGNUPLOTscript[lua] plot \ctxlua{context(1.2 * x + 3

Re: [NTG-context] Lua and module gnuplot: Manipulate Gnuplot script with Lua

2011-12-12 Thread Paul Menzel
] plot \ctxlua{context(1.2 * x + 3)} \stopGNUPLOTscript This won't work. The reason is that contents between \startGNUPLOTscript and \stopGNUPLOTscript are not parsed by ConTeXt on purpose. It was very very very painful if not impossible to get it right with parsing. I

Re: [NTG-context] Lua and module gnuplot: Manipulate Gnuplot script with Lua

2011-12-12 Thread Paul Menzel
Am Montag, den 12.12.2011, 23:13 +0100 schrieb Mojca Miklavec: […] One more example. One thing that would most probably work (I didn't try it) would be the following: \startGNUPLOTscript[name] plot sin(x) t '$\pi = \ctxlua{math.pi()}$' \stopGNUPLOTscript It has some syntax errors

Re: [NTG-context] Passing TeX parameters to the lua functions

2011-12-05 Thread Wolfgang Schuster
\startluacode debug=io.open(debug.txt,w+) function testfun(param) Use the thirddata or userdata namespace for for functions. debug:write(param) -- tex.print(param) end \stopluacode \def\testmac#1{\directlua{testfun('#1')}} \unprotect \def\testmac#1{\ctxlua{testfun(\!!bs\detokenize{#1

Re: [NTG-context] Passing TeX parameters to the lua functions

2011-12-05 Thread Jaroslav Hajtmar
(param) Use the thirddata or userdata namespace for for functions. debug:write(param) -- tex.print(param) end \stopluacode \def\testmac#1{\directlua{testfun('#1')}} \unprotect \def\testmac#1{\ctxlua{testfun(\!!bs\detokenize{#1}\!!es)}} \protect Wolfgang

Re: [NTG-context] Saving module data in tuc file

2011-12-04 Thread Wolfgang Schuster
. \definetwopasslist{test} \newcount\testcount \starttext \immediatesavetwopassdata{test}{}{First Entry} One: \gettwopassdata{test}\twopassdata \startluacode commands.savetwopassdata(test,Second Entry) \stopluacode Two: \ctxlua{commands.gettwopassdata(test)} \stoptext Wolfgang

Re: [NTG-context] Saving module data in tuc file

2011-12-04 Thread Aditya Mahajan
} {\ctxlua{job.files.run(\!!bs\externalfiter::input_file\!!es, \!!bs\externalfiltercommand\!!es)}}} The solution is to remove the test for the first mode. Needs a bit of refactoring to ensure that the solution still works for MkII. (Does anyone use the filter

Re: [NTG-context] Saving module data in tuc file

2011-12-04 Thread Aditya Mahajan
On Sun, 4 Dec 2011, Aditya Mahajan wrote: \def\executeCommand {\doifmode{*first} {\ctxlua{job.files.run(\!!bs\externalfiter::input_file\!!es, \!!bs\externalfiltercommand\!!es)}}} The solution is to remove the test for the first mode. Needs a bit

Re: [NTG-context] feature request

2011-11-14 Thread Aditya Mahajan
function comments.disable() utilities.sequencers.disableaction(textlineactions,thirddata.comments.translate) end comments.disable() \stopluacode \def\enablecomments {\ctxlua{thirddata.comments.enable()}} \def\disablecomments{\ctxlua{thirddata.comments.disable()}} \appendtoks \enablecomments

Re: [NTG-context] feature request

2011-11-14 Thread Hans Hagen
) end function comments.disable() utilities.sequencers.disableaction(textlineactions,thirddata.comments.translate) end comments.disable() \stopluacode \def\enablecomments {\ctxlua{thirddata.comments.enable()}} \def\disablecomments{\ctxlua{thirddata.comments.disable()}} \appendtoks \enablecomments

Re: [NTG-context] feature request

2011-11-14 Thread Aditya Mahajan
\doinstallcomments[#1][#2]% {\ctxlua{thirddata.comments.install(\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es)}} \unexpanded\def\enablecomments[#1]% {\ctxlua{thirddata.comments.enable (\!!bs#1\!!es)}} \unexpanded\def\disablecomments[#1]% {\ctxlua{thirddata.comments.disable(\!!bs#1\!!es)}} \protect

[NTG-context] mp-chem.mpiv bug

2011-11-07 Thread Alan Braslau
}) ; ... 1 \starttext 2 \startchemical 3 \chemical [ONE,Z0] [O] 4 \stopchemical 5 \stoptext 6 \stopchemical ...erence \ctxlua {chemicals.stop()} \egroup \chemicalwidth \wd... l.4

[NTG-context] lua and brackets

2011-11-03 Thread Martin Fechner
Hi all, I try to call a lua-function, but it seems that it doesn't work if the parameter contains squared brackets. Here is a short example: \starttext sometext \reference[myref]{} is \ctxlua{tex.print(\atpage[myref])} \stoptext Is there a way to mask

Re: [NTG-context] lua and brackets

2011-11-03 Thread Hans Hagen
On 3-11-2011 10:15, Martin Fechner wrote: Hi all, I try to call a lua-function, but it seems that it doesn't work if the parameter contains squared brackets. Here is a short example: \starttext sometext \reference[myref]{} is \ctxlua{tex.print(\atpage[myref])} \stoptext Is there a way to mask

Re: [NTG-context] lua and brackets

2011-11-03 Thread Martin Fechner
Am 03.11.2011 12:01, schrieb Hans Hagen: On 3-11-2011 10:15, Martin Fechner wrote: Hi all, I try to call a lua-function, but it seems that it doesn't work if the parameter contains squared brackets. Here is a short example: \starttext sometext \reference[myref]{} is \ctxlua{tex.print

Re: [NTG-context] lua and brackets

2011-11-03 Thread Hans Hagen
sometext \reference[myref]{} is \ctxlua{tex.print(\atpage[myref])} \stoptext Is there a way to mask the brackets? \atpage[myref] My lua function doesn't just print the parameter. I have a function like this: \startluacode function pagesetup(page1,page2) if page1==page2

Re: [NTG-context] lua and brackets

2011-11-03 Thread Martin Fechner
([different pagenumbers]) end end \stopluacode \ctxlua{document.pagesetup(one,two)} \ctxlua{document.pagesetup(one,two-a)} \ctxlua{document.pagesetup(two-a,two-b)} but the reference interface is not yet documented Thanks, the lua solution works fine. One question: is the same possible

Re: [NTG-context] Italic correction spoils XHTML-output

2011-10-31 Thread Aditya Mahajan
this limitation by using \ctxlua{os.copy(...)}. Ideally, one should be able to use \ctxlua{os.rename(...)} but os.rename does not work on Windows. Aditya ___ If your question is of interest to others as well, please add an entry

Re: [NTG-context] xml and lua again

2011-10-28 Thread Wolfgang Schuster
\ctxlua{context(tex.dimen[scratchdimen])} \stoptext Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg

Re: [NTG-context] xml and lua again

2011-10-28 Thread Hans Hagen
\scratchdimen=3pt \number\scratchdimen \ctxlua{context(tex.dimen[scratchdimen])} \stoptext which also means that you can say \scratchcounter=\scratchdimen and test dimens as if they are numbers ... this is why we can have \let\ifzeropt\ifcase which probably no one ever noticed in the source

[NTG-context] Luatex question

2011-10-25 Thread Lutz Haseloff
Hi all, some months ago I printed the name of the current font with following code: \starttext The current font is: \ctxlua{tex.print(font.getfont(font.current()).fullname)}. \stoptext Now I get an error message: ! LuaTeX error main ctx instance:1: no string to print stack traceback

Re: [NTG-context] Luatex question

2011-10-25 Thread luigi scarso
On Tue, Oct 25, 2011 at 2:09 PM, Lutz Haseloff lutz.hasel...@googlemail.com wrote: Hi all, some months ago I printed the name of the current font with following code: \starttext The current font is: \ctxlua{tex.print(font.getfont(font.current()).fullname)}. \stoptext Now I get an error

Re: [NTG-context] Luatex question

2011-10-25 Thread Hans Hagen
On 25-10-2011 14:09, Lutz Haseloff wrote: Hi all, some months ago I printed the name of the current font with following code: \starttext The current font is: \ctxlua{tex.print(font.getfont(font.current()).fullname)}. \stoptext Now I get an error message: ! LuaTeX errormain ctx instance:1

Re: [NTG-context] Luatex question

2011-10-25 Thread Lutz Haseloff
Thank you for your detailed information. 2011/10/25 Hans Hagen pra...@wxs.nl: On 25-10-2011 14:09, Lutz Haseloff wrote: Hi all, some months ago I printed the name of the current font with following code: \starttext The current font is: \ctxlua{tex.print(font.getfont(font.current

Re: [NTG-context] arguments on context call

2011-10-16 Thread Meer, H. van der
Thanks, I was already trying to jump through the hoops of \ctxlua, but this is really simple and exactly what I needed. The offline calls to context/metapost figure production now can get all the information needed to synchronize with the main document. Hans van der Meer On 16 okt. 2011, at 19

[NTG-context] beta

2011-10-12 Thread Hans Hagen
[cambria] \starttext \ctxlua{moduledata.fonts.show_a_lot(Cambria)} \stoptext It probably needs to be improved. Users are welcome to submit additional (language related) sample alphabets etc. It might also become an option for mtx-fonts.lua == There has been a change in storing positional

[NTG-context] \url interaction and splitting

2011-09-15 Thread Aditya Mahajan
\dosetcolorattribute\??ur\c!color \goto{\hyphenatedurl{\ctxlua{structures.references.urls.get(#1,\@@uralternative,\@@urspace)}}}[fileorurl(#1)]% \endgroup} but this makes \url inherit the style from \setupinteraction rather than \setupurl. Also, \url does not support urlalternative for splitting

Re: [NTG-context] MKIV strange results in Adobe Reader

2011-09-08 Thread Peter Rolf
= lpdf.constant(DeviceRGB), I = true } lpdf.registerpagefinalizer(function() lpdf.addtopageattributes(Group,d) end) end \stopluacode \def\pngTransparencyHack{\ctxlua{backends.codeinjections.rgbtransparencygroup()}} \pngTranparencyHack This is what I use here for my RGB based graphics

Re: [NTG-context] Fwd: Bib-module

2011-08-15 Thread Hans Hagen
}% {\getparameters[\??pb][k=\s!unknown,t=article,n=,s=,a=,y=,o=,u=,#1]}% {\getparameters[\??pb][k=#1,t=article,n=,s=,a=,y=,o=,u=]}% \ctxlua{bibtex.hacks.register(\@@pbk)}% \catcode\commentasciicode\othercatcode \dodostartpublication} \def\dodostartpublication#1\stoppublication

[NTG-context] How well do ConTeXt (lua)module for other users?

2011-07-19 Thread Jaroslav Hajtmar
defining by [[ ... ]]. Or must be module consists of two separate files (my-module.lua and my-module.mkiv)? Must I to load the Lua module file (my-module.lua) into ConTeXt module file (my-module.mkiv) by command \ctxlua{dofile(my-module.lua );} and then load module file (my-module.mkiv) into my

Re: [NTG-context] How well do ConTeXt (lua)module for other users?

2011-07-19 Thread Wolfgang Schuster
file, then I have a problem with catcodes inside strings defining by [[ ... ]]. Or must be module consists of two separate files (my-module.lua and my-module.mkiv)? Must I to load the Lua module file (my-module.lua) into ConTeXt module file (my-module.mkiv) by command \ctxlua{dofile(my

Re: [NTG-context] How well do ConTeXt (lua)module for other users?

2011-07-19 Thread Jaroslav Hajtmar
with catcodes inside strings defining by [[ ... ]]. Or must be module consists of two separate files (my-module.lua and my-module.mkiv)? Must I to load the Lua module file (my-module.lua) into ConTeXt module file (my-module.mkiv) by command \ctxlua{dofile(my-module.lua );} and then load module

[NTG-context] Finding values ​​of the context macros inside Lua functions (=expansion inside Lua functions?)

2011-07-17 Thread Jaroslav Hajtmar
context(arg.. is not number.\\par) end if type(tonumber(arg))=='number' then context(arg.. is number.\\par ) else context(arg.. is not number.\\par) end end \stopluacode \starttext \def\value{7} \ctxlua{test('\value');} \blank[big] \ctxlua{test('\\value');} \stoptext

Re: [NTG-context] Finding values ​​of the context macros inside Lua functions (=expansion inside Lua functions?)

2011-07-17 Thread Wolfgang Schuster
else context(The argument \\quotation{%s} is a string.,arg) end end \stopluacode \starttext \ctxlua{test(7)} \ctxlua{test(-4)} \ctxlua{test(text)} \stoptext Wolfgang ___ If your question

Re: [NTG-context] Finding values ​​of the context macros inside Lua functions (=expansion inside Lua functions?)

2011-07-17 Thread Jaroslav Hajtmar
Thanx Wolfgang. But I guess I was wrong to express.. I need to pass parameter '\\macroI' to the function and turn it up a inside luafunction expand to its value. Ie when \def\macroI{6} Then I need when I make in your example \ctxlua{test(\\macroI)} get the result : The argument “6

Re: [NTG-context] Finding values ​​of the context macros inside Lua functions (=expansion inside Lua functions?)

2011-07-17 Thread Wolfgang Schuster
example \ctxlua{test(\\macroI)} get the result : The argument “6” is a positive number and not result The argument “6” is a string. That’s odd because for me \ctxlua{test(\macroI)} results in The argument “6” is a positive number. and \ctxlua{test(\\macroI)} in The argument “6

Re: [NTG-context] Finding values ​​of the context macros inside Lua functions (=expansion inside Lua functions?)

2011-07-17 Thread Jaroslav Hajtmar
: Thanx Wolfgang. But I guess I was wrong to express.. I need to pass parameter '\\macroI' to the function and turn it up a inside luafunction expand to its value. Not possible. Ie when \def\macroI{6} Then I need when I make in your example \ctxlua{test(\\macroI)} get the result

Re: [NTG-context] Finding values ​​of the context macros inside Lua functions (=expansion inside Lua functions?)

2011-07-17 Thread Wolfgang Schuster
context(Invalid command.) end end \stopluacode \starttext \starttabulate \NC \type{\macroI} \EQ \ctxlua{test(\\macroI)} \NC\NR \NC \type{\macroII} \EQ \ctxlua{test(\\macroII)} \NC\NR \NC \type{\macroIII} \EQ \ctxlua{test(\\macroIII)} \NC\NR \NC \type{\foo} \EQ \ctxlua{test

Re: [NTG-context] Finding values ​​of the context macros inside Lua functions (=expansion inside Lua functions?)

2011-07-17 Thread Jaroslav Hajtmar
(Invalid index.) end else context(Invalid command.) end end \stopluacode \starttext \starttabulate \NC \type{\macroI} \EQ \ctxlua{test(\\macroI)} \NC\NR \NC \type{\macroII} \EQ \ctxlua{test(\\macroII)} \NC\NR \NC \type{\macroIII} \EQ \ctxlua

Re: [NTG-context] Optimal way to defining of macros in Luacode in ConTeXt

2011-07-14 Thread Jaroslav Hajtmar
\opencsvfile{% \dosingleempty\doopencsvfile% } \def\doopencsvfile[#1]{% \dosinglegroupempty\dodoopencsvfile } \def\dodoopencsvfile#1{% \iffirstargument \ctxlua{thirddata.scancsv.opencsvfile(#1)} \else \ctxlua{thirddata.scancsv.opencsvfile()} \fi } or other macro etc

Re: [NTG-context] Optimal way to defining of macros in Luacode in ConTeXt

2011-07-14 Thread Hans Hagen
On 14-7-2011 5:12, Jaroslav Hajtmar wrote: To show what macros I want to convert, I mention these examples: \def\opencsvfile{% \dosingleempty\doopencsvfile% } \def\doopencsvfile[#1]{% \dosinglegroupempty\dodoopencsvfile } \def\dodoopencsvfile#1{% \iffirstargument \ctxlua

Re: [NTG-context] context.labeltext(...)

2011-07-04 Thread Willi Egger
) else context() end context.eTD() context.eTR() end context.eTABLE() end \stopluacode \def\maandtabel#1{\ctxlua{monthtable(#1)}} \starttext \maandtabel{2) \stoptext Kind regards

Re: [NTG-context] apos; not working anymore

2011-07-04 Thread Philipp Gesang
(suspecting a misspelling here) but the string is nowhere found in the ConTeXt base directory. Are you sure? Here with version 2011.06.29 09:57 I get [ 20:46:21 = laokoon@aides = ~/context/tex/texmf-context/tex/context/base] grep -n xmlsetent * lxml-ini.mkiv:343:\def\xmlsetentity#1#2{\ctxlua

Re: [NTG-context] break strings

2011-06-13 Thread Hans Hagen
\ThisHelpsLuigiX#1{\ctxlua{LuigiX('#1')}} \def\ThisHelpsLuigiY#1{\ctxlua{LuigiY('#1')}} \def\LuigiYY#1{#1\hskip\zeropoint plus .1pt\relax} The disadvantage of the lua way is that for long strings we end up with a lot of data collected at the lua end that gets passed to tex. Normally this is no real problem

Re: [NTG-context] Getting arguments by Lua

2011-06-09 Thread Peter Münster
On Thu, Jun 09 2011, Procházka Lukáš Ing. - Pontex s. r. o. wrote: but I'd need to get also the source file name (Source.mkiv) and the option (--result - Result.pdf). \starttext result (lua): \ctxlua{context(environment.outputfilename)}\par result (tex): \systemparameter{file} \stoptext

Re: [NTG-context] Random selection of a word in a set with lua and mkiv

2011-06-08 Thread Hans Hagen
\ctxlua{document.r(math physics)} (untested) - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma

Re: [NTG-context] Random selection of a word in a set with lua and mkiv

2011-06-08 Thread Mathieu Dupont
[math.random(1, #arg)]) end\stopluacode\def\CHOOSERANDOM#1{\ctxlua{userdata.random(#1)}}\dorecurse{10}{\CHOOSERANDOM{Maths, Physics, Algebra, Analysis, Chemistry, Geometry, Wave equation, Schrödinger equation}\par}\stoptext Mathieu From: ota...@gmail.com Date: Wed, 8 Jun 2011 18:52:36 +0200

Re: [NTG-context] Random selection of a word in a set with lua and mkiv

2011-06-08 Thread Hans Hagen
userdata.random(...) context(arg[math.random(1, #arg)]) end\stopluacode\def\CHOOSERANDOM#1{\ctxlua{userdata.random(#1)}}\dorecurse{10}{\CHOOSERANDOM{Maths, Physics, Algebra, Analysis, Chemistry, Geometry, Wave equation, Schrödinger equation}\par}\stoptext Because context remembers the seed

Re: [NTG-context] Random selection of a word in a set with lua and mkiv

2011-06-08 Thread Mathieu Dupont
) for some reason. Anyone knows why ? \enableregime[il1]\starttext\startluacode userdata = userdata or {} math.randomseed( os.time() )function userdata.random(...) context(arg[math.random(1, #arg)]) end\stopluacode\def\CHOOSERANDOM#1{\ctxlua{userdata.random(#1

Re: [NTG-context] Random selection of a word in a set with lua and mkiv

2011-06-08 Thread Otared Kavian
. Anyone knows why ? \enableregime[il1] \starttext \startluacode userdata = userdata or {} math.randomseed( os.time() ) function userdata.random(...) context(arg[math.random(1, #arg)]) end \stopluacode \def\CHOOSERANDOM#1{\ctxlua{userdata.random

Re: [NTG-context] xml syntax for \externalfigure

2011-06-04 Thread Thomas A. Schmitz
}, args_present and t) end \stopluacode \startxmlsetups xml:externalfigure \ctxlua{my_externalfigure(\xmlatt{#1}{resource}, {width = \xmlatt{#1}{width}, height = \xmlatt{#1}{height}})} \stopxmlsetups My first idea was \expanded{\externalfigure[...][\doif...]} but it does not work

Re: [NTG-context] xml syntax for \externalfigure

2011-06-03 Thread Peter Münster
for k, v in pairs(t) do if v == then t[k] = nil else args_present = true end end context.externalfigure({file}, args_present and t) end \stopluacode \startxmlsetups xml:externalfigure \ctxlua{my_externalfigure(\xmlatt{#1}{resource

Re: [NTG-context] xml syntax for \externalfigure

2011-06-03 Thread Hans Hagen
\ctxlua{my_externalfigure(\xmlatt{#1}{resource}, {width = \xmlatt{#1}{width}, height = \xmlatt{#1}{height}})} \stopxmlsetups My first idea was \expanded{\externalfigure[...][\doif...]} but it does not work... you can consider passing #1 and using lxml.att at the lua end or go even further

Re: [NTG-context] checking mainlanguage setup

2011-06-01 Thread Hans Hagen
On 1-6-2011 10:14, Hans Hagen wrote: [[ ]] vs is a lua thing ... but when you pass things from within tex, expansions happens the same in both; you can try context(\detokenize{...}) Sorry, that should have been \ctxlua{\detokenize{...}} which takes care of things at the tex end. When

Re: [NTG-context] t-filter: no table created when Unicode characters are included

2011-05-01 Thread Paul Menzel
:: rest-temp-rest.tex :: α - Manually execute the shell command from inside ConTeXt using \ctxlua{os.execute()}. This does not work either. $ more tests/rest.tex % LM does not appear to have Greek letters in unicode slots

Re: [NTG-context] t-filter: no table created when Unicode characters are included

2011-05-01 Thread Peter Münster
the differences in the environment, just do set /tmp/set-shell and run context on: --8---cut here---start-8--- \starttext \ctxlua{os.executeset /tmp/set-context} \stoptext --8---cut here---end---8--- I don't have pandoc, but I'm

Re: [NTG-context] t-filter: no table created when Unicode characters are included

2011-05-01 Thread Aditya Mahajan
explains why luatex sets locale to C. To see the differences in the environment, just do set /tmp/set-shell and run context on: --8---cut here---start-8--- \starttext \ctxlua{os.executeset /tmp/set-context} \stoptext --8---cut here---end

Re: [NTG-context] t-filter: no table created when Unicode characters are included

2011-04-30 Thread Aditya Mahajan
rst file with a unicode letter (no table)? - If that also fails, then a simple markdown file with a unicode letter. - If that also fails, then some other program that reads a file and writes its contents to another file. - Manually execute the shell command from inside ConTeXt using \ctxlua

Re: [NTG-context] Skipping item numbers in an itemized list?

2011-04-27 Thread Aditya Mahajan
]{5} There is no interface to increment the counter by arbitrary amount, but you can define your own interface to structures.counters.add: \unprotected \def\addtostructurecounter [#1]#2{\ctxlua{structures.counters.add (\@@thestructurecounter{#1},1,#2)}} and then use \addtostructurecounter

Re: [NTG-context] Skipping item numbers in an itemized list?

2011-04-27 Thread Ulrike Fischer
somewhere the actual counter by 1 or 2 without having to check the actual number first. There is no interface to increment the counter by arbitrary amount, but you can define your own interface to structures.counters.add: \unprotected \def\addtostructurecounter [#1]#2{\ctxlua

Re: [NTG-context] Skipping item numbers in an itemized list?

2011-04-27 Thread Alasdair McAndrew
interface to structures.counters.add: \unprotected \def\addtostructurecounter [#1]#2{\ctxlua{structures.counters.add (\@@thestructurecounter{#1},1,#2)}} and then use \addtostructurecounter[\currentitemgroupcounter]{2} I would say that's what Alasdair wants. -- Ulrike Fischer

[NTG-context] line numbers in margin from xml in context mkiv

2011-04-26 Thread Jon Crump
\def\svopage{\xmlatt{#1}{n}.} \xmlflush{#1} \stopxmlsetups \startluacode function filter(lb) if math.mod(lb,5) == 0 then context.svopage() context(lb) end end \stopluacode \define[1]\MyNumber% {\ctxlua{filter(#1)}\endgraf} \startxmlsetups xml:lb \xmldoifelse{#1

Re: [NTG-context] label bug with latest beta (2011.04.22)

2011-04-23 Thread Hans Hagen
= lists.result[n] local t = l.titledata if t then texsprint(t.label or default or ) end end and then in strc-lst.mkiv: \edef\currentlistlabel{\ctxlua{structures.lists.label(\currentlistindex,\currentlistlabel

Re: [NTG-context] Some problems creating a wiki page

2011-04-15 Thread Aditya Mahajan
)? The results I get are the same as using texexec, not context. IIRC, there were some security concerns with MkIV: \ctxlua{os.execute(cat /etc/passwd)} Aditya ___ If your question is of interest to others as well, please

Re: [NTG-context] Some problems creating a wiki page

2011-04-15 Thread Cecil Westerhof
.) But it uses texexec (MKII) and not context (MKIV)? The results I get are the same as using texexec, not context. IIRC, there were some security concerns with MkIV:   \ctxlua{os.execute(cat /etc/passwd)} If that is the only problem, you could use shadow passwords. Would be a good idea to mention this. I

Re: [NTG-context] Some problems creating a wiki page

2011-04-15 Thread Hans Hagen
texexec (MKII) and not context (MKIV)? The results I get are the same as using texexec, not context. IIRC, there were some security concerns with MkIV: \ctxlua{os.execute(cat /etc/passwd)} Althoug I admit that I tested it long ago (early days of mkiv) there is some control built

[NTG-context] Symbols Martin Vogel

2011-03-27 Thread Willi Egger
: main ctx instance:1: in main chunk. ... \getnamedglyphdirect ...\ctxlua {fonts.char(#2)} } \dodosymbol ...bol \csname \??ss :#1:#2\endcsname \relax }\relax \fetchsymbol ... {\dodosymbol {#1

Re: [NTG-context] beta

2011-03-26 Thread mathew
instance:35: attempt to index field 'iterators' (a nil value) stack traceback: main ctx instance:35: in function 'show_all' main ctx instance:1: in main chunk. \ShowCompleteFont ... \ctxlua { fonts.show_all() } \stopcolumns \page

Re: [NTG-context] \doif... and Lua

2011-03-25 Thread Wolfgang Schuster
= a} \doifempty{\directlua{return test}} %\doifempty{\directlua{test}} {Yes} {No} \stoptext --- But this gives me always No. - I'm not sure if this is a good way, and whether attempt to use \doif(...) macro is a good idea at all. Any (better) solution? \starttext \ctxlua{test

Re: [NTG-context] \doif... and Lua

2011-03-25 Thread Procházka Lukáš Ing . - Pontex s . r . o .
to use \doif(...) macro is a good idea at all. Any (better) solution? \starttext \ctxlua{test = true} Test is \ctxlua{commands.testcase(test)}{True}{False}. \ctxlua{test = false} Test is \ctxlua{commands.testcase(test)}{True}{False}. \stoptext Wolfgang

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Philipp Gesang
], :, changed[4][2], } local datestr = table.concat(dateform) documentdata.changed.__last_changed = datestr return datestr end \stopluacode \unexpanded\def\getdate{% \ctxlua{context(documentdata.changed.get_changed())}% } \starttext The source of this file was last modified

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Marco
os.date(%Y-%m-%d %H:%M,attr.modification) end end \stopluacode \unexpanded\def\getdate{% \ctxlua{context(modification_date (\jobname.tex))}% } \getdate \stoptext Marco ___ If your question is of interest

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Cecil Westerhof
) if attr.mode ~= directory then return os.date(%Y-%m-%d %H:%M,attr.modification) end end \stopluacode \unexpanded\def\getdate{% \ctxlua{context(modification_date (\jobname.tex))}% } \getdate \stoptext I would like to do something like the following: \getdate would return os.date(%Y

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Aditya Mahajan
) assert (type(attr) == table) if attr.mode ~= directory then return os.date(%Y-%m-%d %H:%M,attr.modification) end end \stopluacode \unexpanded\def\getdate{% \ctxlua{context(modification_date (\jobname.tex))}% } \getdate \stoptext I would like to do something like the following

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Philipp Gesang
{\dosingleempty\dogetdate} \def\dogetdate[#1]% {\ctalua{context(modification_date(\jobname.tex, #1))}} ^ s/\\ctalua/\\ctxlua/ Regards, Philipp \starttext \getdate \stoptext This gives: \dogetdate [#1]-\ctalua {context

<    3   4   5   6   7   8   9   10   11   12   >