From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/36509 Path: news.gmane.org!not-for-mail From: Taco Hoekwater Newsgroups: gmane.comp.tex.context Subject: Re: Greek in luatex Date: Thu, 13 Sep 2007 13:38:03 +0200 Message-ID: <46E9211B.5020206@elvenkind.com> References: <7EFEDA40-D45B-4A94-A9CC-2599CF5CF462@uni-bonn.de> <20070913011518.GA29626@phare.normalesup.org> <46E8E0A6.7030805@elvenkind.com> <20070913102426.GA10571@phare.normalesup.org> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080402000104050609090603" X-Trace: sea.gmane.org 1189683519 23136 80.91.229.12 (13 Sep 2007 11:38:39 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 13 Sep 2007 11:38:39 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Sep 13 13:38:37 2007 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1IVn1j-0005gp-Hg for gctc-ntg-context-518@m.gmane.org; Thu, 13 Sep 2007 13:38:31 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id C00D61FF2F; Thu, 13 Sep 2007 13:38:29 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 16193-04-17; Thu, 13 Sep 2007 13:38:18 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 556691FCEC; Thu, 13 Sep 2007 13:38:18 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id D552C1FCEC for ; Thu, 13 Sep 2007 13:38:15 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 16193-04-16 for ; Thu, 13 Sep 2007 13:38:04 +0200 (CEST) Original-Received: from post-23.mail.nl.demon.net (post-23.mail.nl.demon.net [194.159.73.193]) by ronja.ntg.nl (Postfix) with ESMTP id 02B691FCE3 for ; Thu, 13 Sep 2007 13:38:04 +0200 (CEST) Original-Received: from boo.demon.nl ([82.161.175.147]:57202 helo=[10.10.0.6]) by post-23.mail.nl.demon.net with esmtp (Exim 4.51) id 1IVn1H-0001dQ-Sm for ntg-context@ntg.nl; Thu, 13 Sep 2007 11:38:03 +0000 User-Agent: Thunderbird 1.5.0.10 (X11/20070305) In-Reply-To: <20070913102426.GA10571@phare.normalesup.org> X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 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 X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:36509 Archived-At: This is a multi-part message in MIME format. --------------080402000104050609090603 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Arthur Reutenauer wrote: >> Yes, except that we need a more powerful version (almost like OTPs) if >> we want to handle transcriptions properly. The vital point is that it >> should operate on tokens, not on nodes. > > Yes, sure. OTP would work fine here, but I thought Mark IV had already > something handy. I played a bit, see attachment. Surely Hans will want to improve on this interface, so don't patch any of the core files just now. Best wishes, Taco --------------080402000104050609090603 Content-Type: text/x-tex; name="tokfilter.tex" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="tokfilter.tex" % engine=luatex %D First a hack to the core. two changes: %D * don't force end_cs to be \relax %D * don't remove end_cs from the input stream \ctxlua{ function collectors.install(tag,end_cs) collectors.data[tag] = { } local data = collectors.data[tag] local call = token.command_id("call") local endcs = token.csname_id(end_cs) local expand = collectors.registered local get = token.get_next while true do local t = get() local a, b = t[1], t[3] if b == endcs then tex.print('\\' ..end_cs) return elseif a == call and expand[b] then token.expand() else data[\string#data+1] = t end end end } %D a small extension to the core interface, to have a %D nice wrapper around the lua code \ctxlua { function collectors.handle(tag,handle) collectors.data[tag] = handle(collectors.data[tag]) end } \def\handletokens[#1][#2]{\ctxlua{collectors.handle("#1",#2)}} %D Here starts the document-specific code %D Start capturing tokens in the buffer named 'babel', stop %D at \stopbabel \def\startbabel {\ctxlua{collectors.install("babel", "stopbabel")}} %D The lua mutation function. str is a table containing the captured %D tokens, each itself a three-item table (this is explained in the %D luatex manual) \ctxlua { function convert_babel(str) local t = { } for k,v in ipairs(str) do t[\string#t+1] = tokens.other('*') t[\string#t+1] = v end return t end } %D convert the tokens using that lua function, then %D flush the result \def\stopbabel {\handletokens[babel][convert_babel] \flushtokens[babel]} \starttext \startbabel% some stuff here \stopbabel \stoptext --------------080402000104050609090603 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ --------------080402000104050609090603--