From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/48841 Path: news.gmane.org!not-for-mail From: Khaled Hosny Newsgroups: gmane.comp.tex.context Subject: Re: substitutions Date: Fri, 27 Mar 2009 14:05:03 +0200 Message-ID: <20090327120503.GA10763@khaled-laptop> References: <6faad9f00810070353h170387fm234b5b6a5c75b8c6@mail.gmail.com> <48EBA78A.8040209@wxs.nl> <6faad9f00810081553m5d478338t6d1d0b8a2ca9b5cd@mail.gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1924108186==" X-Trace: ger.gmane.org 1238155600 31432 80.91.229.12 (27 Mar 2009 12:06:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 27 Mar 2009 12:06:40 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri Mar 27 13:07:58 2009 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 1LnAqc-00024V-PZ for gctc-ntg-context-518@m.gmane.org; Fri, 27 Mar 2009 13:07:42 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id CC3ED1FB4E; Fri, 27 Mar 2009 13:06:16 +0100 (CET) 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 00375-07; Fri, 27 Mar 2009 13:05:32 +0100 (CET) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id D5FFD1FB5A; Fri, 27 Mar 2009 13:05:31 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id D9AA71FB5A for ; Fri, 27 Mar 2009 13:05:29 +0100 (CET) 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 17614-01 for ; Fri, 27 Mar 2009 13:05:18 +0100 (CET) Original-Received: from filter4-til.mf.surf.net (filter4-til.mf.surf.net [194.171.167.220]) by ronja.ntg.nl (Postfix) with ESMTP id B8B861FB57 for ; Fri, 27 Mar 2009 13:05:18 +0100 (CET) Original-Received: from rv-out-0708.google.com (rv-out-0708.google.com [209.85.198.247]) by filter4-til.mf.surf.net (8.13.8/8.13.8/Debian-3) with ESMTP id n2RC5Gpw023476 for ; Fri, 27 Mar 2009 13:05:17 +0100 Original-Received: by rv-out-0708.google.com with SMTP id l33so1276695rvb.14 for ; Fri, 27 Mar 2009 05:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:date:from:to:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=oJ/equAFYg4HkevDWszAMm+fcdxaICc6FPLLQS3j3G4=; b=CT3Izdx07XJ2avBGXKT5wiq2A7VurQqM8Z+uLrFlA2kZ/ckHR0vQqpkUgn30r4YQFs fFbjdfcZQWgifVVq+U5l7cE1Sp4Wv0Oi8b27dnCDYEfkAwGO6QQz3JHdzQV8KILw6QYV jbq0MpLGo38uOCh9mlCQo1r7cYgxCkSGPstBE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=FajPGn17e6g35ran4JfG2v/0bAJLAyFIAzfqiN+qMbxGtcOsCQpW4lpyO5vVYpQwch swpjX1EDEe9DfSlLXeEXGA0JxB2ZHFl1MgcsTxfBEpkypO/XPAxUU4O+XCITEjNQIyAg IySZ80751Mf6+QnHdgD27D727GFq7THJjZMH8= Original-Received: by 10.140.132.4 with SMTP id f4mr1050308rvd.291.1238155515898; Fri, 27 Mar 2009 05:05:15 -0700 (PDT) Original-Received: from localhost ([41.237.37.243]) by mx.google.com with ESMTPS id k37sm3236708rvb.28.2009.03.27.05.05.10 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 27 Mar 2009 05:05:13 -0700 (PDT) In-Reply-To: <6faad9f00810081553m5d478338t6d1d0b8a2ca9b5cd@mail.gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=209.85.198.247; country=US; region=CA; city=Mountain View; postalcode=94043; latitude=37.4192; longitude=-122.0574; metrocode=807; areacode=650; http://maps.google.com/maps?q=37.4192,-122.0574&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 200072828 - a05ab7f3dfea - 20090327 X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.220 X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.11 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:48841 Archived-At: --===============1924108186== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="SLDf9lqlvOQaIe6s" Content-Disposition: inline --SLDf9lqlvOQaIe6s Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable (I know this an old thread, but I just happen to exactly the same feature Idris was asking for) On Thu, Oct 09, 2008 at 12:53:47AM +0200, Mojca Miklavec wrote: > usage: ruby scriptname.rb < input.tex > output.tex >=20 > #!/usr/bin/env ruby >=20 > subs_hash =3D { > "Mohamed" =3D> "Mu=E1=B8=A5ammad", > "Idris" =3D> "=D8=A7=D8=AF=D8=B1=D9=8A=D8=B3", > } >=20 > while line =3D STDIN.gets > subs_hash.each do |key,value| > line.gsub!(Regexp.new(key), value) > end > puts line > end Such approach has a major disadvantage, one have to take care of not altering macros and tex commands or we may end with a broken document (I have more general use case where the to be substituted strings can occur in macros as well), and we know that "only TeX can read TeX" :) I'm thinking in lua callback that get fed with text buffers in a similar way to OTPs, so one can use regular expressions to pre-process the text without messing with node list, think in code that replaces 2nd with 2\high{nd} etc. which would be very complex to be done at node list level. Regards, Khaled --=20 Khaled Hosny Arabic localiser and member of Arabeyes.org team Free font developer --SLDf9lqlvOQaIe6s Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAknMwO4ACgkQRoqITGOuyPKolQCfQfOaQsW703YfIB8hdSe7VirR cYQAnAq35g1W+IWVfIm6fktnbJRloENM =+aAn -----END PGP SIGNATURE----- --SLDf9lqlvOQaIe6s-- --===============1924108186== 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 ___________________________________________________________________________________ --===============1924108186==--