ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Getting the content of source lines in a \startlines \stoplines env?
@ 2013-02-04 17:11 Ingo Hohmann
  2013-02-04 17:49 ` Wolfgang Schuster
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo Hohmann @ 2013-02-04 17:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Getting the content of source lines in a \startlines \stoplines env?
  2013-02-04 17:11 Getting the content of source lines in a \startlines \stoplines env? Ingo Hohmann
@ 2013-02-04 17:49 ` Wolfgang Schuster
  2013-02-04 18:05   ` Aditya Mahajan
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfgang Schuster @ 2013-02-04 17:49 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 04.02.2013 um 18:11 schrieb Ingo Hohmann <context@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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Getting the content of source lines in a \startlines \stoplines env?
  2013-02-04 17:49 ` Wolfgang Schuster
@ 2013-02-04 18:05   ` Aditya Mahajan
  2013-02-04 18:08     ` luigi scarso
  0 siblings, 1 reply; 4+ messages in thread
From: Aditya Mahajan @ 2013-02-04 18:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, 4 Feb 2013, Wolfgang Schuster wrote:

> 			context("{\\bf %s}",l)
> 			context(true)

What does context(true) do?

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Getting the content of source lines in a \startlines \stoplines env?
  2013-02-04 18:05   ` Aditya Mahajan
@ 2013-02-04 18:08     ` luigi scarso
  0 siblings, 0 replies; 4+ messages in thread
From: luigi scarso @ 2013-02-04 18:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, Feb 4, 2013 at 7:05 PM, Aditya Mahajan <adityam@umich.edu> wrote:
> 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
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-02-04 18:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-04 17:11 Getting the content of source lines in a \startlines \stoplines env? Ingo Hohmann
2013-02-04 17:49 ` Wolfgang Schuster
2013-02-04 18:05   ` Aditya Mahajan
2013-02-04 18:08     ` luigi scarso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).