[NTG-context] new beta

Hans Hagen pragma at wxs.nl
Mon Mar 11 00:46:38 CET 2013


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")


local mf = string.formatters["whatever %!tex! and %!xml!"]

... mf("$ 100","a&b")


context("whatever %!tex! and %!xml!","$ 100","a&b")

(Someone should add that to the wiki I guess).


                                           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

More information about the ntg-context mailing list