* Node for startbuffer.
@ 2013-01-09 13:54 Andre Caldas
2013-01-09 15:30 ` Hans Hagen
0 siblings, 1 reply; 11+ messages in thread
From: Andre Caldas @ 2013-01-09 13:54 UTC (permalink / raw)
To: ConTeXt users
Hello!
Given some
\startbuffer
Blah, blah, blah...
\stopbuffer
I'd like to get a "node tree" corresponding to how the buffer would be
processed at a given point. Using luatex, I'd like to identify certain
sub-nodes and change their attributes (to be specific: transparency).
Any hint on how to do it?
Also, are there any good examples on how to use "nodes"?
André Caldas.
___________________________________________________________________________________
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] 11+ messages in thread
* Re: Node for startbuffer.
2013-01-09 13:54 Node for startbuffer Andre Caldas
@ 2013-01-09 15:30 ` Hans Hagen
2013-01-09 15:59 ` Andre Caldas
2013-01-09 20:57 ` Andre Caldas
0 siblings, 2 replies; 11+ messages in thread
From: Hans Hagen @ 2013-01-09 15:30 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 1/9/2013 2:54 PM, Andre Caldas wrote:
> Hello!
>
> Given some
>
> \startbuffer
> Blah, blah, blah...
> \stopbuffer
>
> I'd like to get a "node tree" corresponding to how the buffer would be
> processed at a given point. Using luatex, I'd like to identify certain
> sub-nodes and change their attributes (to be specific: transparency).
>
> Any hint on how to do it?
here's an example (I'll add it to the cld manual):
\starttext
\definecolor[mytransparency][a=1,t=.5]
\startluacode
local enabled = false
local count = 0
function userdata.processmystuff(head)
if enabled then
count = count + 1
for n in node.traverse(head) do
logs.report("node","run %s: %s",count,n)
if count % 2 == 0 then
nodes.tracers.transparencies.set(n,"mytransparency")
end
end
return head, true
end
return head, false
end
function userdata.enablemystuff()
enabled = true
end
function userdata.disablemystuff()
enabled = false
end
nodes.tasks.appendaction("processors", "normalizers",
"userdata.processmystuff")
\stopluacode
\startbuffer
whatever \hbox{you} want
\stopbuffer
\ctxlua{userdata.enablemystuff()}
\par \getbuffer \par
\ctxlua{userdata.disablemystuff()}
\stoptext
> Also, are there any good examples on how to use "nodes"?
all over context ...
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Node for startbuffer.
2013-01-09 15:30 ` Hans Hagen
@ 2013-01-09 15:59 ` Andre Caldas
2013-01-09 20:57 ` Andre Caldas
1 sibling, 0 replies; 11+ messages in thread
From: Andre Caldas @ 2013-01-09 15:59 UTC (permalink / raw)
To: Hans Hagen; +Cc: mailing list for ConTeXt users
> here's an example (I'll add it to the cld manual):
Wow!!! Thank you for your time, Hans!
I will study your sample... :-)
Cheers,
André Caldas.
___________________________________________________________________________________
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] 11+ messages in thread
* Re: Node for startbuffer.
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
1 sibling, 1 reply; 11+ messages in thread
From: Andre Caldas @ 2013-01-09 20:57 UTC (permalink / raw)
To: Hans Hagen; +Cc: mailing list for ConTeXt users
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
André Caldas.
___________________________________________________________________________________
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] 11+ messages in thread
* Re: Node for startbuffer.
2013-01-09 20:57 ` Andre Caldas
@ 2013-01-10 0:19 ` Hans Hagen
2013-01-10 12:18 ` Andre Caldas
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Hans Hagen @ 2013-01-10 0:19 UTC (permalink / raw)
To: Andre Caldas; +Cc: mailing list for ConTeXt users
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Node for startbuffer.
2013-01-10 0:19 ` Hans Hagen
@ 2013-01-10 12:18 ` Andre Caldas
2013-01-10 13:00 ` Hans Hagen
2013-01-12 14:49 ` Andre Caldas
2013-01-29 20:57 ` Andre Caldas
2 siblings, 1 reply; 11+ messages in thread
From: Andre Caldas @ 2013-01-10 12:18 UTC (permalink / raw)
To: Hans Hagen; +Cc: mailing list for ConTeXt users
>> How do I identify a specific node? Like...
>> [...]
>
> 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.
> [...]
> \hbox \boxmarker{mymarker}{2}
Can't the mark be a string?
André Caldas.
___________________________________________________________________________________
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] 11+ messages in thread
* Re: Node for startbuffer.
2013-01-10 12:18 ` Andre Caldas
@ 2013-01-10 13:00 ` Hans Hagen
0 siblings, 0 replies; 11+ messages in thread
From: Hans Hagen @ 2013-01-10 13:00 UTC (permalink / raw)
To: Andre Caldas; +Cc: mailing list for ConTeXt users
On 1/10/2013 1:18 PM, Andre Caldas wrote:
>>> How do I identify a specific node? Like...
>>> [...]
>>
>> 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.
>> [...]
>> \hbox \boxmarker{mymarker}{2}
>
> Can't the mark be a string?
currently not (not hard to implement, but no time now).
-----------------------------------------------------------------
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Node for startbuffer.
2013-01-10 0:19 ` Hans Hagen
2013-01-10 12:18 ` Andre Caldas
@ 2013-01-12 14:49 ` Andre Caldas
2013-01-13 17:51 ` Hans Hagen
2013-01-29 20:57 ` Andre Caldas
2 siblings, 1 reply; 11+ messages in thread
From: Andre Caldas @ 2013-01-12 14:49 UTC (permalink / raw)
To: Hans Hagen; +Cc: mailing list for ConTeXt users
> I've added the markers code to the beta so that we have an
> abstract way to deal with such matters.
> [...]
> Node lists are processed \hbox \boxmarker{mymarker}{1} {nested from
> [...]
Does it have to be an "hbox"?
>
> It's somewhat experimental. Up to you to update the wiki.
I've never updated the wiki... I am a bit scared... but I will... :-)
> I've added the example to the cld manual.
How can I see it?
André Caldas.
___________________________________________________________________________________
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] 11+ messages in thread
* Re: Node for startbuffer.
2013-01-12 14:49 ` Andre Caldas
@ 2013-01-13 17:51 ` Hans Hagen
0 siblings, 0 replies; 11+ messages in thread
From: Hans Hagen @ 2013-01-13 17:51 UTC (permalink / raw)
To: Andre Caldas; +Cc: mailing list for ConTeXt users
On 1/12/2013 3:49 PM, Andre Caldas wrote:
>> I've added the markers code to the beta so that we have an
>> abstract way to deal with such matters.
>> [...]
>> Node lists are processed \hbox \boxmarker{mymarker}{1} {nested from
>> [...]
>
> Does it have to be an "hbox"?
no, but only a few node types make sense .. it all depends on what you
want to do
>> It's somewhat experimental. Up to you to update the wiki.
>
> I've never updated the wiki... I am a bit scared... but I will... :-)
I bet Sietse will keep an eye on your edits.
>> I've added the example to the cld manual.
>
> How can I see it?
google for cld-mkiv.pdf or browse the pragma website
-----------------------------------------------------------------
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Node for startbuffer.
2013-01-10 0:19 ` Hans Hagen
2013-01-10 12:18 ` Andre Caldas
2013-01-12 14:49 ` Andre Caldas
@ 2013-01-29 20:57 ` Andre Caldas
2013-01-31 10:42 ` Sietse Brouwer
2 siblings, 1 reply; 11+ messages in thread
From: Andre Caldas @ 2013-01-29 20:57 UTC (permalink / raw)
To: mailing list for ConTeXt users
> It's somewhat experimental. Up to you to update the wiki.
Anyone can suggest a category for it?
http://wiki.contextgarden.net/Category:Commands
Nodes?
André Caldas.
___________________________________________________________________________________
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] 11+ messages in thread
* Re: Node for startbuffer.
2013-01-29 20:57 ` Andre Caldas
@ 2013-01-31 10:42 ` Sietse Brouwer
0 siblings, 0 replies; 11+ messages in thread
From: Sietse Brouwer @ 2013-01-31 10:42 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi André,
> Anyone can suggest a category for it?
> http://wiki.contextgarden.net/Category:Commands
>
> Nodes?
Yep. Creating [[Category:Command/Nodes]] seems like a good idea. To
create the command page, navigate to the intended title (e.g.
Command/boxmarker), click ‘Create’ in the top right, and
copy-and-modify the command page template that you can find here:
http://wiki.contextgarden.net/Help:Command_reference#Command_page_template
Possibly add it to the category [[Category:Command/LuaTeX]], too.
If you find yourself having questions about the wiki, or just wanting
help, even for trivial stuff, just poke me on my talk page:
http://wiki.contextgarden.net/User_talk:Esteis
Or send me a private e-mail, of course, that's also fine.
Hans wrote:
> I've added the example to the cld manual.
...
> google for cld-mkiv.pdf or browse the pragma website
For the benefit of future people:
http://www.pragma-ade.com/general/manuals/cld-mkiv.pdf
It's on page 33, in section 4.4, "Node lists".
Cheers,
Sietse
On Tue, Jan 29, 2013 at 9:57 PM, Andre Caldas <andre.em.caldas@gmail.com> wrote:
>> It's somewhat experimental. Up to you to update the wiki.
>
> Anyone can suggest a category for it?
> http://wiki.contextgarden.net/Category:Commands
>
> Nodes?
>
>
> André Caldas.
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
___________________________________________________________________________________
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] 11+ messages in thread
end of thread, other threads:[~2013-01-31 10:42 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-09 13:54 Node for startbuffer 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
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
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).