From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/36522 Path: news.gmane.org!not-for-mail From: Arthur Reutenauer Newsgroups: gmane.comp.tex.context Subject: Re: Greek in luatex Date: Thu, 13 Sep 2007 20:36:57 +0200 Message-ID: <20070913183657.GC32644@phare.normalesup.org> References: <7EFEDA40-D45B-4A94-A9CC-2599CF5CF462@uni-bonn.de> <20070913011518.GA29626@phare.normalesup.org> <46E8E0A6.7030805@elvenkind.com> <20070913102426.GA10571@phare.normalesup.org> <46E9211B.5020206@elvenkind.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="NzB8fVQJ5HfG6fxh" X-Trace: sea.gmane.org 1189708866 20449 80.91.229.12 (13 Sep 2007 18:41:06 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 13 Sep 2007 18:41:06 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Sep 13 20:41:03 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 1IVtcU-0001BA-H8 for gctc-ntg-context-518@m.gmane.org; Thu, 13 Sep 2007 20:40:54 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 0D81D20007; Thu, 13 Sep 2007 20:40:54 +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 04970-03; Thu, 13 Sep 2007 20:40:53 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 982B02001A; Thu, 13 Sep 2007 20:37:06 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 481422001A for ; Thu, 13 Sep 2007 20:37:04 +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 04970-02-2 for ; Thu, 13 Sep 2007 20:36:58 +0200 (CEST) Original-Received: from nef2.ens.fr (nef2.ens.fr [129.199.96.40]) by ronja.ntg.nl (Postfix) with ESMTP id 7BAB11FFFE for ; Thu, 13 Sep 2007 20:36:58 +0200 (CEST) Original-Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef2.ens.fr (8.13.6/1.01.28121999) with ESMTP id l8DIavqW030112 for ; Thu, 13 Sep 2007 20:36:58 +0200 (CEST) X-Envelope-To: Original-Received: by phare.normalesup.org (Postfix, from userid 1008) id B2FC43806D; Thu, 13 Sep 2007 20:36:57 +0200 (CEST) Content-Disposition: inline In-Reply-To: <46E9211B.5020206@elvenkind.com> User-Agent: Mutt/1.5.13 (2006-08-11) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.1.4 (nef2.ens.fr [129.199.96.32]); Thu, 13 Sep 2007 20:36:58 +0200 (CEST) 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:36522 Archived-At: --NzB8fVQJ5HfG6fxh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline > 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. Fantastic! Now I played a bit with your file myself, and compared with the behaviour of an OTP which has the same action: you can see that macros arguments between square brackets are preserved by OTP, whereas your function (obviously) converts everything unconditionally. How difficult would it be to program the same behaviour, that is, make collectors.handle pass to convert_babel only contiguous ranges of characters that are situated outside matching brackets? --NzB8fVQJ5HfG6fxh Content-Type: text/x-tex; charset=us-ascii Content-Disposition: attachment; filename="tokfilter_otp.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]} \usetypescript[palatino][ec] \starttext \section{With Taco's \type{\startbabel}} \startbabel% some stuff here \blank[medium] some other stuff \switchtobodyfont[palatino] \subsection{More stuff} stuff stuff stuff \stopbabel \blank[big] \section{With an \tt OTP} % Do the same as convert_babel, with a simple OTP (stars.otp) \ocp\stars=stars \ocplist\StarsOCP=\addbeforeocplist1\stars\nullocplist \pushocplist\StarsOCP some stuff here \blank[medium] some other stuff \switchtobodyfont[palatino] \subsection{More stuff} stuff stuff stuff \stoptext --NzB8fVQJ5HfG6fxh Content-Type: application/octet-stream Content-Disposition: attachment; filename="stars.ocp" Content-Transfer-Encoding: base64 AAAADwAAAAIAAAACAAAAAAAAAAAAAAABAAAABwAAAAcXAAAAAgAAKgMAAAEkAAAAGAAAAAMA AAEkAAAA --NzB8fVQJ5HfG6fxh Content-Type: application/vnd.oasis.opendocument.presentation-template Content-Disposition: attachment; filename="stars.otp" Content-Transfer-Encoding: quoted-printable input: 2 ;=0Aoutput: 2 ;=0A=0Aexpressions:=0A=0A. =3D> "*" \1 ;=0A --NzB8fVQJ5HfG6fxh 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 ___________________________________________________________________________________ --NzB8fVQJ5HfG6fxh--