2
votes
1answer
111 views

How to let Lua see the contents of a variable rather than just the variable name in ConTeXt?

I have some Lua code which searches for "①" and "②" within some text and prints only the text displayed between: \startluacode userdata = userdata or {} function userdata.printbetween(str, ...
7
votes
2answers
691 views

How to check if a value is not equal using TeX conditionals?

I have a value defined in a macro, e.g.: \mymacro{apple} I need to check if a value does not equal a string, e.g.: IF #1 NOT EQUAL TO "apple" THEN PRINT "It is not a apple, it is #1." FI I ...
4
votes
1answer
411 views

How to use string.find from Lua in ConTeXt?

I am trying to make some conditionals with Lua, which check if some text is found within a string. Unfortunately, when I compile it, I get: ! LuaTeX error <main ctx instance>:4: bad argument #1 ...
7
votes
2answers
416 views

How to display special symbols in ConTeXt which are processed by Lua?

I have a ConTeXt document containing many special characters. I have followed the instructions at Which symbols need to be escaped in ConTeXt? to ensure they can all display properly in the document, ...
4
votes
2answers
462 views

Using macro variables with Lua in ConTeXt

I need to make some macros in ConTeXt. I have tried to use Lua code, but I do not understand how to mix ConTeXt source and Lua source together. Here is an example: \define[3]\textmacro{ \startlua ...
3
votes
1answer
140 views

ConTeXt's user namespace seems somewhat empty

With ConTeXt ver: 2010.05.24 13:05 MKIV fmt: 2010.12.18 int: english/english the ConTeXt code \starttext \message{one} \directlua{print(1)} \message{two} \usercode{print(2)} ...
6
votes
2answers
282 views

How to register a callback in ConTeXt

In ConTeXt mkiv, how do I register a callback? callback.register() does nothing (and IIRC most callbacks are frozen anyway) and somewhere I found tasks.appendaction, but this gives me an error that ...