From: Hans Hagen <pragma@wxs.nl>
To: Andre Caldas <andre.em.caldas@gmail.com>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Node for startbuffer.
Date: Thu, 10 Jan 2013 01:19:00 +0100 [thread overview]
Message-ID: <50EE08F4.3020307@wxs.nl> (raw)
In-Reply-To: <CADVh14X5=23es_rh4e78cB9gGx6fSD0Hitq=cnmrtdxknzKm-Q@mail.gmail.com>
On 1/9/2013 9:57 PM, Andre Caldas wrote:
> Another question...
>
>> function userdata.processmystuff(head)
>
> Shall I use this?
> userdata = userdata or {}
>
>
>> \startbuffer
>> whatever \hbox{you} want
>> \stopbuffer
>
> How do I identify a specific node? Like...
>
> \startbuffer
> Will this be
> \boxtobechanged{transparent?}
> \stopbuffer
Here is a start. I've added the markers code to the beta so that we have
an abstract way to deal with such matters.
\setupbodyfont[dejavu]
\definemarker[mymarker]
\definecolor[mymarker:1][r=.6]
\definecolor[mymarker:2][g=.6]
\definecolor[mymarker:3][r=.6,g=.6]
\startluacode
local setcolor = nodes.tracers.colors.setlist
local getmarker = nodes.markers.get
local hlist_code = nodes.codes.hlist
local traverse_id = node.traverse_id
function userdata.processmystuff(head)
for n in traverse_id(hlist_code,head) do
local m = getmarker(n,"mymarker")
if m then
setcolor(n.list,"mymarker:" .. m)
end
end
return head, true
end
nodes.tasks.appendaction("processors", "after", "userdata.processmystuff")
nodes.tasks.disableaction("processors", "userdata.processmystuff")
\stopluacode
\starttext
\startluacode
nodes.tasks.enableaction("processors", "userdata.processmystuff")
\stopluacode
Node lists are processed \hbox \boxmarker{mymarker}{1} {nested from
\hbox{inside}
out} which is not what you might expect. But, \hbox {coloring} does not
\hbox
{happen} really nested here, more \hbox {in} \hbox
\boxmarker{mymarker}{2} {the}
\hbox {order} \hbox {of} \hbox \boxmarker{mymarker}{3} {processing}.
\startluacode
nodes.tasks.disableaction("processors", "userdata.processmystuff")
\stopluacode
\stoptext
It's somewhat experimental. Up to you to update the wiki. I've added the
example to the cld manual.
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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________
next prev parent reply other threads:[~2013-01-10 0:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-09 13:54 Andre Caldas
2013-01-09 15:30 ` Hans Hagen
2013-01-09 15:59 ` Andre Caldas
2013-01-09 20:57 ` Andre Caldas
2013-01-10 0:19 ` Hans Hagen [this message]
2013-01-10 12:18 ` Andre Caldas
2013-01-10 13:00 ` Hans Hagen
2013-01-12 14:49 ` Andre Caldas
2013-01-13 17:51 ` Hans Hagen
2013-01-29 20:57 ` Andre Caldas
2013-01-31 10:42 ` Sietse Brouwer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50EE08F4.3020307@wxs.nl \
--to=pragma@wxs.nl \
--cc=andre.em.caldas@gmail.com \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).