Hi Thomas,

Sorry for the delay in the reply, I was travelling last week.

On Sat, 26 Jan 2008, Thomas A. Schmitz wrote:

>
> On Jan 24, 2008, at 12:19 AM, Aditya Mahajan wrote:
>
>> Another option is Gema <http://gema.sourceforge.net/new/index.shtml>
>> (also has a lua library gelhttp://gema.sourceforge.net/new/
>> gel.shtml). You can define regions and matching nested braces quite
>> easily.
>>
>> Aditya
>
> I remember I had a look at gema before but couldn't really find out
> what was special about it and would warrant further attention. I also
> haven't seen anything about nested braces etc. (which would be great
> for processing TeX files but is a major pain in the back with regexs).
> You seem to know more about it: could you give an example of how it's
> possible to have nested braces in a gema pattern?

Nested patterns is something where gema really excels. Here is a gema 
script to convert \footnote{{something}} to \footnote{something}

:\\footnote\W\{\{<matchbrace>\}\}=\\footnote\{$1\}
matchbrace:\{#\}=\{#\}
matchbrace:\\<Y1>=\\$1

Save it as footnote.gema and then run

gema -f footnote.gema tex-file > output-file

It handles these expressions correctly:

\footnote{{This $\frac{a}{b^{c+d}}$ is a strange footnote}}

\footnote{{This $\frac{a}{b^{c+d}}$ is a strange footnote with multiple {nested
{expressions}}}}

\footnote{{This $\frac{\left[\frac {a}{b}\right\}}{c}$ is a strange 
footnote}}

It is much easier to write than regular expressions. Unfortunately, gema 
expressions can be as hard as regular expressions to read.

Aditya


___________________________________________________________________________________
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