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
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
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
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
:
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
{%
\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
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
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
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
= buffers.getcontent(specialparagraph)
text = string.gsub(text,\n\n, ¶ )
context(text)
end
\stopluacode
\def\startspecialparagraph
{\dostartbuffer[specialparagraph][startspecialparagraph][stopspecialparagraph]}
\def\stopspecialparagraph
{\ctxlua{userdata.specialparagraph
...
\dosetchemicaltext ...usestyleparameter \@cmstyle
\dousecolorparameter \@cmc...
\inlinechemical ...mode \hbox {\dosetchemicaltext
\ctxlua {chemicals.inline(...
l.39 Hydrogen is denoted
\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
[realpageno]) then
context(rightpage)
else
context(leftpage)
end
return true
end
}
end
\stopluacode
\starttext
\ctxlua
)
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
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
= userdata or { }
function userdata.myheadertext(s)
context.setupheadertexts{
function()
context.labeltext(s)
context(: )
return true
end
}
end
\stopluacode
\starttext
\ctxlua
)
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
)
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
)
context.setupheadertexts{s}
end
\stopluacode
\starttext
\ctxluamyheadertext{Headertext}}
String are passed with braces.
\ctxlua{documentdata.myheadertext(Headertext)}
Wolfgang
___
If your question
)
-- context.space()
context(: )
context(s)
end }
end
\stopluacode
\ctxlua{documentdata.myheadertext(Headertext)}
\starttext
\input knuth
\stoptext
Wolfgang
___
If your question
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
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
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
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
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
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
]
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
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
\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
(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
.
\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
}
{\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
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
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
)
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
\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
})
;
...
1 \starttext
2 \startchemical
3 \chemical [ONE,Z0] [O]
4 \stopchemical
5 \stoptext
6
\stopchemical ...erence \ctxlua {chemicals.stop()}
\egroup \chemicalwidth \wd...
l.4
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
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
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
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
([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
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
\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
\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
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
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
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
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
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
[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
\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
= 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
}%
{\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
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
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
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
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
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
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
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
:
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
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
(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
\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
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
)
else
context()
end
context.eTD()
context.eTR()
end
context.eTABLE()
end
\stopluacode
\def\maandtabel#1{\ctxlua{monthtable(#1)}}
\starttext
\maandtabel{2)
\stoptext
Kind regards
(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
\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
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
\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
[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
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
) 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
.
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
}, 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
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
\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
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
::
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
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
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
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
]{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
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
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
\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
= 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
)? 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
.)
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
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
:
main ctx instance:1: in main chunk.
...
\getnamedglyphdirect ...\ctxlua {fonts.char(#2)}
}
\dodosymbol ...bol \csname \??ss :#1:#2\endcsname
\relax }\relax
\fetchsymbol ... {\dodosymbol {#1
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
= 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
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
],
:,
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
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
)
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
)
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
{\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
701 - 800 of 1165 matches
Mail list logo