Am 04.02.2013 um 18:11 schrieb Ingo Hohmann <cont...@ingohohmann.de>:

> Hi,
> 
> in another thread I got an answer to the question, how to format lines in an 
> environment automatically.
> Is there a way to get the content of source lines? For example, to save the 
> line content into a variable?


You can save the content in a buffer and process the content with Lua.

\startluacode

userdata              = userdata              or { }
userdata.linescontent = userdata.linescontent or { }

local linescontent = userdata.linescontent

function linescontent.process()
        local lines = string.splitlines(buffers.getcontent("linescontent"))
        context.startlines()
        for i=1,#lines do
                local l = lines[i]
                if i == 1 then
                        context("{\\bf %s}",l)
                        context(true)
                elseif i == 2 then
                        context("{\\tt %s}",l)
                        context(true)
                else
                        context("%s",l)
                        context(true)
                end
        end
        context.stoplines()
end

\stopluacode

\def\startlinescontent
  {\grabbufferdata[linescontent][startlinescontent][stoplinescontent]}

\def\stoplinescontent
  {\ctxlua{userdata.linescontent.process()}}

\starttext

\startlinescontent
One
Two
Three
Four
Five
Six
\stoplinescontent

\stoptext

Wolfgang
___________________________________________________________________________________
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
___________________________________________________________________________________

Reply via email to