From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/77078 Path: news.gmane.org!not-for-mail From: Philipp Gesang Newsgroups: gmane.comp.tex.context Subject: Re: [callbacks] proper registration, node subtypes Date: Tue, 26 Jun 2012 14:08:15 +0200 Message-ID: <20120626120815.GA7589@phlegethon> References: <20120625133924.GB31738@phlegethon> <4FE87402.3000708@wxs.nl> <20120625145031.GC31738@phlegethon> <4FE9994F.6060403@wxs.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1681421644==" X-Trace: dough.gmane.org 1340712418 23770 80.91.229.3 (26 Jun 2012 12:06:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 26 Jun 2012 12:06:58 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Jun 26 14:06:55 2012 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SjUXm-0003dL-Ai for gctc-ntg-context-518@m.gmane.org; Tue, 26 Jun 2012 14:06:54 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 33939101FC; Tue, 26 Jun 2012 14:06:54 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id XAZLQCF7delO; Tue, 26 Jun 2012 14:06:50 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id B9817101E7; Tue, 26 Jun 2012 14:06:50 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 0FDF9101E7 for ; Tue, 26 Jun 2012 14:06:50 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id GQuNi-igq0je for ; Tue, 26 Jun 2012 14:06:47 +0200 (CEST) Original-Received: from filter4-til.mf.surf.net (filter4-til.mf.surf.net [194.171.167.220]) by balder.ntg.nl (Postfix) with ESMTP id 6DF76101DD for ; Tue, 26 Jun 2012 14:06:47 +0200 (CEST) Original-Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.210.211]) by filter4-til.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id q5QC6k7v031770 for ; Tue, 26 Jun 2012 14:06:46 +0200 Original-Received: from ix.urz.uni-heidelberg.de (cyrus-portal.urz.uni-heidelberg.de [129.206.100.176]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id q5QC6i9l021263 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 26 Jun 2012 14:06:45 +0200 Original-Received: from extmail.urz.uni-heidelberg.de (extmail.urz.uni-heidelberg.de [129.206.100.140]) by ix.urz.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id q5QC6isl029260 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 26 Jun 2012 14:06:44 +0200 Original-Received: from localhost (dslb-188-104-147-056.pools.arcor-ip.net [188.104.147.56]) (authenticated bits=0) by extmail.urz.uni-heidelberg.de (8.13.4/8.13.1) with ESMTP id q5QC6gWQ016617 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Tue, 26 Jun 2012 14:06:43 +0200 Mail-Followup-To: mailing list for ConTeXt users In-Reply-To: <4FE9994F.6060403@wxs.nl> X-Operating-System: Linux phlegethon 3.3.7-1-ARCH X-License: "CC-BY-SA 3.0" User-Agent: Mutt/1.5.21 (2010-09-15) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=129.206.210.211; country=DE; region=01; city=Heidelberg; latitude=49.4167; longitude=8.7000; http://maps.google.com/maps?q=49.4167,8.7000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0VHr06KjI - 0af8648c63f4 - 20120626 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.220 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.13 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:77078 Archived-At: --===============1681421644== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tThc/1wpZn/ma/RB" Content-Disposition: inline --tThc/1wpZn/ma/RB Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable =C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7 > On 25-6-2012 16:50, Philipp Gesang wrote: > >=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7 > > > >>On 25-6-2012 15:39, Philipp Gesang wrote: > >> > >>> - Does the difference wrt node subtype matter assuming I only > >>> (a) copy glyph nodes and (b) manipulate their .char field? > >> > >>not that much, it's just a state signal for font processing > > > >Good to know. > > > >>>Any insights on this matter would be greatly appreciated. Regards > >>>Philipp > >> > >>it all depends on what you want to do > > > >Traverse the node list of a paragraph before line break from head > >to tail in sequential order, recursing into sublists where they > >appear. The callback removes and inserts nodes: which ones > >depends on the nodes already processed (has a state). > > > >Using the previous example code, > > > > \startfoo > > a\hbox{b}c > > \stopfoo > > > >should result in the traversal , , . >=20 > \starttext >=20 > \startluacode >=20 > local function processnestedlist(head,n) > local current, done =3D head, false > while current do > local id =3D current.id > if id =3D=3D nodes.nodecodes.hlist or id =3D=3D nodes.nodecodes.v= list then > local _, d =3D processnestedlist(current.list,n) > if d then > done =3D true > end > elseif id =3D=3D nodes.nodecodes.hglue_code and current.leader th= en > local _, d =3D processnestedlist(current.leader,n) > if d then > done =3D true > end > elseif id =3D=3D nodes.nodecodes.glyph then -- todo: dics nodes > n =3D n + 1 > print(n,utf.char(current.char)) > end > current =3D current.next > end > return head, done, n > end >=20 >=20 > thirddata =3D thirddata or {} > thirddata.test =3D thirddata.test or { } >=20 > thirddata.test.one =3D function(head) > local head, done, n =3D processnestedlist(head,0) > print("n of glyphs",n) > return head, done > end >=20 > nodes.tasks.appendaction ("processors","before","thirddata.test.one") >=20 > \stopluacode >=20 > \ruledhbox to 10cm {\strut hello \ruledhbox{brave new} world > \cleaders\hbox{!}\hfil} >=20 > \stoptext First of all, thanks for the snippet. It=E2=80=99s insightful already wrt to the fact that nodes.installattributehandler is considered unnecessary. But the problem persists. With the code a\hbox{b}c I get the following output: 1 b n of glyphs 1 1 a 2 b 2 c n of glyphs 2 So the sequence is , , , where it should be , , --- the hbox is still processed first, which I was attempting to avoid. (Also, the invisible string =E2=80=9Ccontext=E2=80=9D follows if the callback is active until the end of file.) Regards Philipp >=20 > ----------------------------------------------------------------- > 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 > ----------------------------------------------------------------- >=20 >=20 > _________________________________________________________________________= __________ > If your question is of interest to others as well, please add an entry to= the Wiki! >=20 > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-co= ntext > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > _________________________________________________________________________= __________ --=20 () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments --tThc/1wpZn/ma/RB Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iEYEARECAAYFAk/ppi8ACgkQ02lYlJYWs9JPYwCfQXycCpboOPPhE2dRFicC/r/k UtkAoI2Im4ZQsI56MvbZrIiLRsvTGbvn =1IKv -----END PGP SIGNATURE----- --tThc/1wpZn/ma/RB-- --===============1681421644== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --===============1681421644==--