ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* lpeg substitution
@ 2009-08-11  9:34 Thomas A. Schmitz
  2009-08-11 10:59 ` Hans Hagen
  0 siblings, 1 reply; 9+ messages in thread
From: Thomas A. Schmitz @ 2009-08-11  9:34 UTC (permalink / raw)
  To: mailing ConTeXt users list for

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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-08-12  9:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-11  9:34 lpeg substitution Thomas A. Schmitz
2009-08-11 10:59 ` Hans Hagen
2009-08-11 11:21   ` Thomas A. Schmitz
2009-08-11 12:35     ` Hans Hagen
2009-08-11 15:14       ` Thomas A. Schmitz
2009-08-11 22:01         ` Hans Hagen
2009-08-12  6:51           ` Taco Hoekwater
2009-08-12  8:32             ` Hans Hagen
2009-08-12  9:04               ` Thomas A. Schmitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).