Hi,
I chucked it in here, for lack of a better place.
http://wiki.contextgarden.net/String_Manipulation#String_formatter
I don't understand what they whitespace does: I tried to test it with
this code, and changing the number did nothing.
\starttext
\startluacode
x = 999
context("\\type{my%wpoints}", x)
context.par()
context("my %w points", x)
\stopluacode
\stoptext
And perhaps somebody could add two columns to the wiki with example
input and output?
Cheers,
Sietse
--
Sietse Brouwer -- sbbrouwer@gmail.com -- +31 6 13.456.848
Thorbeckehof 101 -- 2343 DR Oegstgeest -- the Netherlands
MSN: sietse@gawab.com -- ICQ: 341232104
On 11 March 2013 00:46, Hans Hagen
Hi,
I uploaded a beta. The most important change is that the 'context' function now uses the formatters mechanism instead of Lua's format.
This has several benefits. First of all it's in most cases faster (I measured upto 3 times) but it also permits us to support some more:
integer %...i number integer %...d number unsigned %...u number utf character %...c number hexadecimal %...x number HEXADECIMAL %...X number octal %...o number string %...s string number float %...f number exponential %...e number exponential %...E number autofloat %...g number autofloat %...G number force tostring %...S any force tostring %Q any force tonumber %N number (strip leading zeros) signed number %I number rounded number %r number 0xhexadecimal %...h character number 0xHEXADECIMAL %...H character number U+hexadecimal %...u character number U+HEXADECIMAL %...U character number points %p number (scaled points) basepoints %b number (scaled points) table concat %...t table boolean (logic) %l boolean BOOLEAN %L boolean whitespace %...w
More info can be found in cld-mkiv.pdf. There I also explain how to create specific formatters and how to extend them. In the default formatter there are two extensions that can be used as:
string.formatters["whatever %!tex! and %!xml!"]("$ 100","a&b")
or
local mf = string.formatters["whatever %!tex! and %!xml!"]
... mf("$ 100","a&b")
or
context("whatever %!tex! and %!xml!","$ 100","a&b")
(Someone should add that to the wiki I guess).
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ 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-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________