* combining start/stop environments
@ 2003-04-13 14:11 Guy Worthington
2003-04-13 15:23 ` Patrick Gundlach
0 siblings, 1 reply; 4+ messages in thread
From: Guy Worthington @ 2003-04-13 14:11 UTC (permalink / raw)
Hello,
I'd like to introduce new code by highlighting it with a background.
For instance the following snippet of code does what I want:
-----
\starttext
\input tufte
\setupcolors[state=start]
\startbackground
\startJV
import java.io.IOException ;
import org.xml.sax.SAXException ;
\stopJV
\stopbackground
\input tufte
\stoptext
-----
I'd like to get the two nested environments startbackground/startJV,
grouped together under a single concept, in this case the single
concept startNewCode.
I thought I'd just slurp up the argument nested between the keywords
\startNewCode and \stopNewCode into memory and then process the
argument. This is my attempt:
-----
\definetype [typeJV] [option=JV,palet=graypretty]
\def\startNewCode{\blank[medium]
\begingroup
\catcode`\\=12
\STARTNewCode}
{ \catcode`\|=0 \catcode`\\=12
|long|gdef|STARTNewCode#1\stopNewCode{%
|startbackground
|typeJV{#1}
|stopbackground
|blank[medium]
|endgroup}}
\starttext
\input tufte
\startNewCode
import java.io.IOException ;
import org.xml.sax.SAXException ;
\stopNewCode
\input tufte
\stoptext
-----
This unfortunately doesn't work. It gets rid of blank lines and
doesn't pretty-print. I realize my attempt is naive, but I've run out
of ideas of how to combine a background with a verbatim argument.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: combining start/stop environments
2003-04-13 14:11 combining start/stop environments Guy Worthington
@ 2003-04-13 15:23 ` Patrick Gundlach
2003-04-14 8:55 ` Guy Worthington
0 siblings, 1 reply; 4+ messages in thread
From: Patrick Gundlach @ 2003-04-13 15:23 UTC (permalink / raw)
Guy Worthington <guyw@multiline.com.au> writes:
Hi,
[...]
> I'd like to get the two nested environments startbackground/startJV,
> grouped together under a single concept, in this case the single
> concept startNewCode.
what about this?
\starttext
\input tufte
\setupcolors[state=start]
\definetyping[NewCode][before=\startbackground,
after=\stopbackground,
option=JV]
\startNewCode
import java.io.IOException ;
import org.xml.sax.SAXException ;
\stopNewCode
\input tufte
\stoptext
> I thought I'd just slurp up the argument nested between the keywords
> \startNewCode and \stopNewCode into memory and then process the
> argument. This is my attempt:
... too complicated for me :) If the above does not do what you need,
say so. Perhaps I will look closer. But verbatim code look rather
tricky to me, all those 1000 options for prettyprinting are confusing
me.
Patrick
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: combining start/stop environments
2003-04-13 15:23 ` Patrick Gundlach
@ 2003-04-14 8:55 ` Guy Worthington
2003-04-14 9:11 ` Patrick Gundlach
0 siblings, 1 reply; 4+ messages in thread
From: Guy Worthington @ 2003-04-14 8:55 UTC (permalink / raw)
Patrick wrote
> Guy wrote:
>> [a convoluted method to combine a background with pretty-printing
>> environment]
> what about this?
> \definetyping[NewCode][before=\startbackground,
> after=\stopbackground,
> option=JV]
That's the effect I'm after. It looks so obvious, now I've seen the
answer.
Thanks Patrick
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: combining start/stop environments
2003-04-14 8:55 ` Guy Worthington
@ 2003-04-14 9:11 ` Patrick Gundlach
0 siblings, 0 replies; 4+ messages in thread
From: Patrick Gundlach @ 2003-04-14 9:11 UTC (permalink / raw)
Guy Worthington <guyw@multiline.com.au> writes:
Hi,
> That's the effect I'm after. It looks so obvious, now I've seen the
> answer.
It's simple, isn't it? I was trying some low level ConTeXt hacking
and after a while I came across this commmand, and I said to myself:
Lucky me that I did not post some of this ugly TeX hack to the list...
It happens to me so often that I do some ugly stuff in ConTeXt and
after a while I find out that there is already some high level
interface for it.
Patrick
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-04-14 9:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-13 14:11 combining start/stop environments Guy Worthington
2003-04-13 15:23 ` Patrick Gundlach
2003-04-14 8:55 ` Guy Worthington
2003-04-14 9:11 ` Patrick Gundlach
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).