ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Khaled Hosny <khaledhosny@eglug.org>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: substitutions
Date: Fri, 27 Mar 2009 14:05:03 +0200	[thread overview]
Message-ID: <20090327120503.GA10763@khaled-laptop> (raw)
In-Reply-To: <6faad9f00810081553m5d478338t6d1d0b8a2ca9b5cd@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1172 bytes --]

(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 #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
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	other threads:[~2009-03-27 12:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-05 23:57 substitutions Idris Samawi Hamid ادريس سماوي حامد
2008-10-07 10:53 ` substitutions Mojca Miklavec
2008-10-07 18:16   ` substitutions Hans Hagen
2008-10-08 12:41     ` substitutions Idris Samawi Hamid ادريس سماوي حامد
2008-10-08 14:46       ` substitutions Mojca Miklavec
2008-10-08 15:43         ` substitutions Idris Samawi Hamid
2008-10-08 22:53       ` substitutions Mojca Miklavec
2009-03-27 12:05         ` Khaled Hosny [this message]
2009-03-29  1:27           ` substitutions: can i send this? Idris Samawi Hamid ادريس سماوي حامد
2009-03-29 17:25             ` Khaled Hosny
2009-03-29 17:37               ` Hans Hagen
2008-10-08 12:34   ` substitutions Idris Samawi Hamid ادريس سماوي حامد

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090327120503.GA10763@khaled-laptop \
    --to=khaledhosny@eglug.org \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).