Getting the content of source lines in a \startlines \stoplines env?
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? Thank you in advance, Ingo
Am 04.02.2013 um 18:11 schrieb Ingo Hohmann
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
On Mon, Feb 4, 2013 at 7:05 PM, Aditya Mahajan
On Mon, 4 Feb 2013, Wolfgang Schuster wrote:
context("{\\bf %s}",l) context(true)
What does context(true) do?
Aditya
""" Newline tokens are injected by passing true to the context command: """ see cld-mkiv.pdf -- luigi
participants (4)
-
Aditya Mahajan
-
Ingo Hohmann
-
luigi scarso
-
Wolfgang Schuster