On 2-10-2011 04:58, Aditya Mahajan wrote:
Why can't I change the color and style when using processisolatedwords?

\defineframed[colored][foregroundcolor=red,foregroundstyle=\bfc,location=low]

\starttext
\colored{What}
\processisolatedwords {\input ward \relax } \colored
\stoptext

Also \processwords is defined twice, first in syst-aux which is then
overwritten by the definition in supp-box.

indeed as the supp-box one has some advantages

anyhow, I tried to fix it (qualifies as dirty trick)

\defineframed[colored][foregroundcolor=red,foregroundstyle=\bfc\underbar,location=low]

\starttext

\colored{What}

\processisolatedwords {\input ward \relax} \colored

\stoptext

should work ok now. Of course you can consider other approaches:

(wifiyable):

\startluacode

local words = lpeg.split(lpeg.patterns.spacer,io.loaddata(resolvers.findfile("ward.tex")) or "")

    for i=1,#words do
        if i == 1 then
            context.dontleavehmode()
        else
            context.space()
        end
        context.colored(words[i])
    end

\stopluacode

or without temporary array:

\startluacode
    local i = 0

    local function reset()
        i = 0
    end

    local function apply(s)
        i = i + 1
        if i == 1 then
            context.dontleavehmode()
        else
            context.space()
        end
        context.colored(words[i])
    end

local splitter = lpeg.P(true)/reset * lpeg.splitter(lpeg.patterns.spacer,apply)

    lpeg.match(splitter,io.loaddata(resolvers.findfile("ward.tex")) or "")

\stopluacode

maybe I should add this variant ..

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
-----------------------------------------------------------------
_______________________________________________
dev-context mailing list
dev-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/dev-context

Reply via email to