From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/52173 Path: news.gmane.org!not-for-mail From: "Thomas A. Schmitz" Newsgroups: gmane.comp.tex.context Subject: lpeg substitution Date: Tue, 11 Aug 2009 11:34:41 +0200 Message-ID: <00765789-37D5-4318-9055-898AAA792135@uni-bonn.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v935.3) Content-Type: text/plain; charset="us-ascii"; Format="flowed"; DelSp="yes" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1249983324 27788 80.91.229.12 (11 Aug 2009 09:35:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Aug 2009 09:35:24 +0000 (UTC) To: mailing ConTeXt users list for Original-X-From: ntg-context-bounces@ntg.nl Tue Aug 11 11:35:17 2009 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from [195.12.62.10] (helo=balder.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1ManlF-0000tS-8L for gctc-ntg-context-518@m.gmane.org; Tue, 11 Aug 2009 11:35:17 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 2D920C9A77; Tue, 11 Aug 2009 11:35:03 +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 UbhWMWvg530W; Tue, 11 Aug 2009 11:34:59 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 31D3DC9A70; Tue, 11 Aug 2009 11:34:59 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 787B5C9A70 for ; Tue, 11 Aug 2009 11:34:58 +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 S4q7M5L2PPjz for ; Tue, 11 Aug 2009 11:34:56 +0200 (CEST) Original-Received: from uni-bonn.de (mail.uni-bonn.de [131.220.15.113]) by balder.ntg.nl (Postfix) with ESMTP id 98503C9A68 for ; Tue, 11 Aug 2009 11:34:56 +0200 (CEST) Original-Received: from [87.178.69.110] (account tschmit1@uni-bonn.de HELO [192.168.0.2]) by fe2.uni-bonn.de (CommuniGate Pro SMTP 5.2.12) with ESMTPA id 21720945 for ntg-context@ntg.nl; Tue, 11 Aug 2009 11:34:56 +0200 X-Mailer: Apple Mail (2.935.3) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 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:52173 Archived-At: Hi all, I'm working on my Greek module again and am trying to filter and massage the input via lpeg, but there's something I don't quite get. As a minimal example: suppose I want to substitute A and B in my input with X and leave all other letters alone. Here's my attempt: \startluacode do local replace = { A = "X", B = "X", } local dosub = (lpeg.Cs(1)) / replace local subs = (dosub)^0 function test (string) tex.sprint(lpeg.match(subs,string)) end end \stopluacode \def\Substitute#1{\ctxlua{test("#1")}} \starttext \Substitute{ABC} \stoptext It substitutes alright, but the "C" is not included in the stream which ctxlua gives to TeX. How can I modify my lpeg pattern? Thanks, and all best Thomas ___________________________________________________________________________________ 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 ___________________________________________________________________________________