[dev-context] Comma lists and Lua
Hans Hagen
pragma at wxs.nl
Thu Jun 7 18:28:46 CEST 2012
On 7-6-2012 18:14, Wolfgang Schuster wrote:
> Hi,
>
> in the following example the space before the “one” in the line
>
> \ctxlua{userdata.commalist(" one, two, three")}
>
> is visible in the output. I guess this counts as bug because in the assignment
> list the space before “a=x” is removed.
you can change line 113 in util-prs.lua:
local pattern = spaces * Ct(value*(separator*value)^0)
> Example:
>
> \starttext
>
> \startluacode
>
> userdata = userdata or {}
>
> function userdata.commalist(list)
> local list = utilities.parsers.settings_to_array(list)
> context.starttabulate()
> for index, value in next, list do
> context.NC()
> context.quotation(index)
> context.NC()
> context.quotation(value)
> context.NC()
> context.NR()
> end
> context.stoptabulate()
> end
>
> function userdata.parameters(list)
> local list = utilities.parsers.settings_to_hash(list)
> context.starttabulate()
> for key, value in next, list do
> context.NC()
> context.quotation(key)
> context.NC()
> context.quotation(value)
> context.NC()
> context.NR()
> end
> context.stoptabulate()
> end
>
> \stopluacode
>
> \ctxlua{userdata.commalist("one,two,three")}
> \ctxlua{userdata.commalist(" one, two, three")}
> \ctxlua{userdata.parameters("a=x,b=y,c=z")}
> \ctxlua{userdata.parameters(" a=x, b=y, c=z")}
>
> \stoptext
>
> Wolfgang
> _______________________________________________
> dev-context mailing list
> dev-context at ntg.nl
> http://www.ntg.nl/mailman/listinfo/dev-context
--
-----------------------------------------------------------------
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 dev-context
mailing list