On 13-6-2011 3:58, Wolfgang Schuster wrote:
Am 13.06.2011 um 15:40 schrieb luigi scarso:
Where is the difference ?
The TeX solution is faster.
\define[1]\ThisHelps {\handletokens#1\with{\hskip 0pt plus .1pt\firstofoneargument}}
\define[1]\ThisHelpsLuigi {\startluacode s='#1' s= string.gsub(s,'(.)',"\%1\\hskip 0sp plus .1pt") context(s) \stopluacode}
\showframe
\starttext
\testfeatureonce{10000}{\ThisHelps {abcde123xyz}}% \testfeatureonce{10000}{\ThisHelpsLuigi{abcde123xyz}}
\stoptext
A few variants ... \startluacode local gsub = string.gsub function LuigiX(s) local s = gsub(s,'.',"\%1\\hskip 0sp plus .1pt") context(s) end local gmatch = string.gmatch function LuigiY(s) local LuigiYY = context.LuigiYY for s in gmatch(s,".") do LuigiYY(s) end end \stopluacode \def\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. 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 -----------------------------------------------------------------