(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
> 
> #!/usr/bin/env ruby
> 
> subs_hash = {
>   "Mohamed" => "Muḥammad",
>   "Idris" => "ادريس",
> }
> 
> while line = 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


-- 
 Khaled Hosny
 Arabic localiser and member of Arabeyes.org team
 Free font developer

Attachment: signature.asc
Description: Digital signature

___________________________________________________________________________________
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
___________________________________________________________________________________

Reply via email to