* {{ double braces }} @ 2008-01-21 14:45 Steffen Wolfrum 2008-01-21 15:02 ` Mikael Persson 2008-01-23 20:49 ` Peter Münster 0 siblings, 2 replies; 24+ messages in thread From: Steffen Wolfrum @ 2008-01-21 14:45 UTC (permalink / raw) To: mailing list for ConTeXt users Hi, I would like to use in my documents double braces for the footnote – for easily matching entire footnotes with RegEx (thus it can't confuse with the nested braces) ... text\footnote{{this is {\it one} tiny note\index{note}!}} ... and match the entire footnote with search regex for \\footnote\{\ {.+\}\} Is this save? Or are there unwanted side-effects when using \footnote {{ ... }} ? Steffen ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-01-21 14:45 {{ double braces }} Steffen Wolfrum @ 2008-01-21 15:02 ` Mikael Persson 2008-01-21 15:53 ` Steffen Wolfrum 2008-01-23 20:49 ` Peter Münster 1 sibling, 1 reply; 24+ messages in thread From: Mikael Persson @ 2008-01-21 15:02 UTC (permalink / raw) To: mailing list for ConTeXt users Hi Steffen, I don't really know regex, but how does your double brace work with the following \footnote{{This $\frac{a}{b^{c+d}}$ is a strange footnote}} note the double }} in the math formula. /Micke P On Jan 21, 2008 3:45 PM, Steffen Wolfrum <context@st.estfiles.de> wrote: > Hi, > > I would like to use in my documents double braces for the footnote – > for easily matching entire footnotes with RegEx (thus it can't > confuse with the nested braces) ... > > text\footnote{{this is {\it one} tiny note\index{note}!}} > > ... and match the entire footnote with search regex for \\footnote\{\ > {.+\}\} > > > Is this save? Or are there unwanted side-effects when using \footnote > {{ ... }} ? > > Steffen > > > > ___________________________________________________________________________________ > 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 > ___________________________________________________________________________________ > ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-01-21 15:02 ` Mikael Persson @ 2008-01-21 15:53 ` Steffen Wolfrum 0 siblings, 0 replies; 24+ messages in thread From: Steffen Wolfrum @ 2008-01-21 15:53 UTC (permalink / raw) To: mailing list for ConTeXt users math formula is one of the few things I definitely don't have to take care for =o) up to now ... thanks for the tip! steffen Am 21.01.2008 um 16:02 schrieb Mikael Persson: > Hi Steffen, > > I don't really know regex, but how does your double brace work with > the following > > \footnote{{This $\frac{a}{b^{c+d}}$ is a strange footnote}} > > note the double }} in the math formula. > > /Micke P > > On Jan 21, 2008 3:45 PM, Steffen Wolfrum <context@st.estfiles.de> > wrote: >> Hi, >> >> I would like to use in my documents double braces for the footnote – >> for easily matching entire footnotes with RegEx (thus it can't >> confuse with the nested braces) ... >> >> text\footnote{{this is {\it one} tiny note\index{note}!}} >> >> ... and match the entire footnote with search regex for \\footnote\{\ >> {.+\}\} >> >> >> Is this save? Or are there unwanted side-effects when using \footnote >> {{ ... }} ? >> >> Steffen >> >> >> >> _____________________________________________________________________ >> ______________ >> 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 >> _____________________________________________________________________ >> ______________ >> > ______________________________________________________________________ > _____________ > 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 > ______________________________________________________________________ > _____________ ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-01-21 14:45 {{ double braces }} Steffen Wolfrum 2008-01-21 15:02 ` Mikael Persson @ 2008-01-23 20:49 ` Peter Münster 2008-01-23 21:50 ` Peter Münster 1 sibling, 1 reply; 24+ messages in thread From: Peter Münster @ 2008-01-23 20:49 UTC (permalink / raw) To: mailing list for ConTeXt users On Mon, Jan 21 2008, Steffen Wolfrum wrote: > > I would like to use in my documents double braces for the footnote – > for easily matching entire footnotes with RegEx (thus it can't > confuse with the nested braces) ... > > text\footnote{{this is {\it one} tiny note\index{note}!}} > > ... and match the entire footnote with search regex for \\footnote\{\ > {.+\}\} Hi Steffen, have you already tried http://archive.contextgarden.net/message/20060730.070820.14c7c91e.en.html (extended regexp)? Cheers, Peter -- http://pmrb.free.fr/contact/ ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-01-23 20:49 ` Peter Münster @ 2008-01-23 21:50 ` Peter Münster 2008-01-23 22:17 ` Thomas A. Schmitz 0 siblings, 1 reply; 24+ messages in thread From: Peter Münster @ 2008-01-23 21:50 UTC (permalink / raw) To: mailing list for ConTeXt users On Wed, Jan 23 2008, Peter Münster wrote: > On Mon, Jan 21 2008, Steffen Wolfrum wrote: > > > > I would like to use in my documents double braces for the footnote – > > for easily matching entire footnotes with RegEx (thus it can't > > confuse with the nested braces) ... > > > > text\footnote{{this is {\it one} tiny note\index{note}!}} > > > > ... and match the entire footnote with search regex for \\footnote\{\ > > {.+\}\} > > have you already tried > http://archive.contextgarden.net/message/20060730.070820.14c7c91e.en.html > (extended regexp)? I've just seen, that it does not work for nested braces: \footnote{x{y}z}: ok \footnote{x{y{z}}}: not ok The next one (normal regexp, not extended) has support for up to one level of nesting: \\footnote{[^{}]*\([^{}]*{[^{}]*\([^{}]*{[^{}]*}[^{}]*\)*[^{}]*}[^{}]*\)*[^{}]*} These examples seem to work: \footnote{x{y}z} \footnote{x{y{z}}} \footnote{x{y}z} \footnote{x{y{z}}x{y{z}}x{y}z} \footnote{x{y{z}}x{y{z}y{z}y}x{y}z} Cheers, Peter -- http://pmrb.free.fr/contact/ ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-01-23 21:50 ` Peter Münster @ 2008-01-23 22:17 ` Thomas A. Schmitz 2008-01-23 23:19 ` Aditya Mahajan 2008-01-26 10:52 ` Taco Hoekwater 0 siblings, 2 replies; 24+ messages in thread From: Thomas A. Schmitz @ 2008-01-23 22:17 UTC (permalink / raw) To: mailing list for ConTeXt users On Jan 23, 2008, at 10:50 PM, Peter Münster wrote: > I've just seen, that it does not work for nested braces: > \footnote{x{y}z}: ok > \footnote{x{y{z}}}: not ok > > The next one (normal regexp, not extended) has support for up to one > level > of nesting: > > \\footnote{[^{}]*\([^{}]*{[^{}]*\([^{}]*{[^{}]*}[^{}]*\)*[^{}]*} > [^{}]*\)*[^{}]*} > > These examples seem to work: > \footnote{x{y}z} > \footnote{x{y{z}}} > \footnote{x{y}z} > \footnote{x{y{z}}x{y{z}}x{y}z} > \footnote{x{y{z}}x{y{z}y{z}y}x{y}z} > > Cheers, Peter You could also use a nice scripting language like ... lua!! lua has support for "balanced strings," so no nesting trickery is needed, see http://www.lua.org/pil/20.2.html (scroll to the bottom of the page). Or you could try and nag Hans into giving a nice tutorial on the lua lpeg library at Bohinj! :-) 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] 24+ messages in thread
* Re: {{ double braces }} 2008-01-23 22:17 ` Thomas A. Schmitz @ 2008-01-23 23:19 ` Aditya Mahajan 2008-01-26 10:11 ` Thomas A. Schmitz 2008-01-26 10:52 ` Taco Hoekwater 1 sibling, 1 reply; 24+ messages in thread From: Aditya Mahajan @ 2008-01-23 23:19 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1: Type: TEXT/PLAIN, Size: 1306 bytes --] On Wed, 23 Jan 2008, Thomas A. Schmitz wrote: > > On Jan 23, 2008, at 10:50 PM, Peter Münster wrote: > >> I've just seen, that it does not work for nested braces: >> \footnote{x{y}z}: ok >> \footnote{x{y{z}}}: not ok >> >> The next one (normal regexp, not extended) has support for up to one >> level >> of nesting: >> >> \\footnote{[^{}]*\([^{}]*{[^{}]*\([^{}]*{[^{}]*}[^{}]*\)*[^{}]*} >> [^{}]*\)*[^{}]*} Wow. This shows regexes are easier to write than read. I would have never managed to read what this does (and I know regexes fairly well). >> These examples seem to work: >> \footnote{x{y}z} >> \footnote{x{y{z}}} >> \footnote{x{y}z} >> \footnote{x{y{z}}x{y{z}}x{y}z} >> \footnote{x{y{z}}x{y{z}y{z}y}x{y}z} >> >> Cheers, Peter > > You could also use a nice scripting language like ... lua!! lua has > support for "balanced strings," so no nesting trickery is needed, see http://www.lua.org/pil/20.2.html > (scroll to the bottom of the page). Or you could try and nag Hans > into giving a nice tutorial on the lua lpeg library at Bohinj! :-) Another option is Gema <http://gema.sourceforge.net/new/index.shtml> (also has a lua library gel http://gema.sourceforge.net/new/gel.shtml). You can define regions and matching nested braces quite easily. Aditya [-- 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: {{ double braces }} 2008-01-23 23:19 ` Aditya Mahajan @ 2008-01-26 10:11 ` Thomas A. Schmitz 2008-02-06 7:01 ` Aditya Mahajan 0 siblings, 1 reply; 24+ messages in thread From: Thomas A. Schmitz @ 2008-01-26 10:11 UTC (permalink / raw) To: mailing list for ConTeXt users 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 Hi 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? 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] 24+ messages in thread
* Re: {{ double braces }} 2008-01-26 10:11 ` Thomas A. Schmitz @ 2008-02-06 7:01 ` Aditya Mahajan 2008-02-06 9:11 ` Steffen Wolfrum 2008-02-12 15:09 ` Thomas A. Schmitz 0 siblings, 2 replies; 24+ messages in thread From: Aditya Mahajan @ 2008-02-06 7:01 UTC (permalink / raw) To: mailing list for ConTeXt users 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: {{ double braces }} 2008-02-06 7:01 ` Aditya Mahajan @ 2008-02-06 9:11 ` Steffen Wolfrum 2008-02-06 16:36 ` Aditya Mahajan 2008-02-06 20:17 ` Otared Kavian 2008-02-12 15:09 ` Thomas A. Schmitz 1 sibling, 2 replies; 24+ messages in thread From: Steffen Wolfrum @ 2008-02-06 9:11 UTC (permalink / raw) To: mailing list for ConTeXt users Actually I use this to highlight footnotes in my texteditor: colorize entire footnotes for for easier reading. I am quite happy to have (on MacOSX) a text-editor that gives such "syntax coloring" flexibility: it is Satoshi Matsumoto's Jedit X. And here RegularExpressions are used for that purpose. If someone knows an editor that does "syntax coloring" with lua or gema, I'd be very interested! Thanks, Steffen ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-02-06 9:11 ` Steffen Wolfrum @ 2008-02-06 16:36 ` Aditya Mahajan 2008-02-06 19:20 ` Hans van der Meer 2008-02-06 20:17 ` Otared Kavian 1 sibling, 1 reply; 24+ messages in thread From: Aditya Mahajan @ 2008-02-06 16:36 UTC (permalink / raw) To: mailing list for ConTeXt users On Wed, 6 Feb 2008, Steffen Wolfrum wrote: > Actually I use this to highlight footnotes in my texteditor: colorize > entire footnotes for for easier reading. > > I am quite happy to have (on MacOSX) a text-editor that gives such > "syntax coloring" flexibility: it is Satoshi Matsumoto's Jedit X. And > here RegularExpressions are used for that purpose. > > If someone knows an editor that does "syntax coloring" with lua or > gema, I'd be very interested! In vim you can highlight comands and their "regions" using region start, region end, and region contains. That can be used to highlight footnotes. (I once used something similar for highlighting sections in LaTeX, but no longer have that code). Of course, vim comes with rest of its baggage. 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: {{ double braces }} 2008-02-06 16:36 ` Aditya Mahajan @ 2008-02-06 19:20 ` Hans van der Meer 2008-02-06 20:01 ` Steffen Wolfrum 0 siblings, 1 reply; 24+ messages in thread From: Hans van der Meer @ 2008-02-06 19:20 UTC (permalink / raw) To: mailing list for ConTeXt users On Wed, 6 Feb 2008, Steffen Wolfrum wrote: > Actually I use this to highlight footnotes in my texteditor: colorize > entire footnotes for for easier reading. > > I am quite happy to have (on MacOSX) a text-editor that gives such > "syntax coloring" flexibility: it is Satoshi Matsumoto's Jedit X. And > here RegularExpressions are used for that purpose. > > If someone knows an editor that does "syntax coloring" with lua or > gema, I'd be very interested! BBEdit on MacOSX also recognizes lua files, at least in version 8.7.2 Hans van der Meer ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-02-06 19:20 ` Hans van der Meer @ 2008-02-06 20:01 ` Steffen Wolfrum 2008-02-06 20:16 ` Hans van der Meer 0 siblings, 1 reply; 24+ messages in thread From: Steffen Wolfrum @ 2008-02-06 20:01 UTC (permalink / raw) To: mailing list for ConTeXt users Am 06.02.2008 um 20:20 schrieb Hans van der Meer: > On Wed, 6 Feb 2008, Steffen Wolfrum wrote: > >> Actually I use this to highlight footnotes in my texteditor: colorize >> entire footnotes for for easier reading. >> >> I am quite happy to have (on MacOSX) a text-editor that gives such >> "syntax coloring" flexibility: it is Satoshi Matsumoto's Jedit X. And >> here RegularExpressions are used for that purpose. >> >> If someone knows an editor that does "syntax coloring" with lua or >> gema, I'd be very interested! > > BBEdit on MacOSX also recognizes lua files, at least in version 8.7.2 Sure, but how does that affect syntax coloring?? Steffen ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-02-06 20:01 ` Steffen Wolfrum @ 2008-02-06 20:16 ` Hans van der Meer 0 siblings, 0 replies; 24+ messages in thread From: Hans van der Meer @ 2008-02-06 20:16 UTC (permalink / raw) To: mailing list for ConTeXt users On 6 feb 2008, at 21:01, Steffen Wolfrum wrote: > > Am 06.02.2008 um 20:20 schrieb Hans van der Meer: > >> On Wed, 6 Feb 2008, Steffen Wolfrum wrote: >> >>> Actually I use this to highlight footnotes in my texteditor: >>> colorize >>> entire footnotes for for easier reading. >>> >>> I am quite happy to have (on MacOSX) a text-editor that gives such >>> "syntax coloring" flexibility: it is Satoshi Matsumoto's Jedit X. >>> And >>> here RegularExpressions are used for that purpose. >>> >>> If someone knows an editor that does "syntax coloring" with lua or >>> gema, I'd be very interested! >> >> BBEdit on MacOSX also recognizes lua files, at least in version 8.7.2 > > Sure, but how does that affect syntax coloring?? It recognizes keywords, string constants and comments, each can have a different (user definable) color. The comment start (usually --) and optionally comment end can be chosen via a preference panel. Hans van der Meer ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-02-06 9:11 ` Steffen Wolfrum 2008-02-06 16:36 ` Aditya Mahajan @ 2008-02-06 20:17 ` Otared Kavian 1 sibling, 0 replies; 24+ messages in thread From: Otared Kavian @ 2008-02-06 20:17 UTC (permalink / raw) To: mailing list for ConTeXt users On 6 févr. 08, at 10:11, Steffen Wolfrum wrote: > […] > > If someone knows an editor that does "syntax coloring" with lua or > gema, I'd be very interested! Hi Steffen, Smultron does this on MacOS X: http://smultron.sourceforge.net/ In fact one can define easily a set of syntax colouring for almost anything with Smultron. Best regards: OK ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-02-06 7:01 ` Aditya Mahajan 2008-02-06 9:11 ` Steffen Wolfrum @ 2008-02-12 15:09 ` Thomas A. Schmitz 2008-02-12 15:15 ` Hans Hagen 1 sibling, 1 reply; 24+ messages in thread From: Thomas A. Schmitz @ 2008-02-12 15:09 UTC (permalink / raw) To: mailing list for ConTeXt users Hi Aditya, now I need to apologize for being so slow to reply: thanks a lot, this looks really fascinating! I don't know how many things I've read on the web to understand if regexps can handle nested delimiters or not (I think the long and short of it was that on some mathematical principle it just isn't possible); there is some pretty obscure perl stuff that might be able to do it but is highly experimental. If gema really can do this, it should be a godsend for processing TeX files. I have it installed now on my OS X box (but couldn't build the gel binary) and am looking forward to experimenting with it. All best, and thanks! Thomas On Feb 6, 2008, at 8:01 AM, Aditya Mahajan wrote: > 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: {{ double braces }} 2008-02-12 15:09 ` Thomas A. Schmitz @ 2008-02-12 15:15 ` Hans Hagen 2008-02-12 17:39 ` Aditya Mahajan 0 siblings, 1 reply; 24+ messages in thread From: Hans Hagen @ 2008-02-12 15:15 UTC (permalink / raw) To: mailing list for ConTeXt users Thomas A. Schmitz wrote: > Hi Aditya, > > now I need to apologize for being so slow to reply: thanks a lot, this > looks really fascinating! I don't know how many things I've read on > the web to understand if regexps can handle nested delimiters or not > (I think the long and short of it was that on some mathematical > principle it just isn't possible); there is some pretty obscure perl > stuff that might be able to do it but is highly experimental. If gema > really can do this, it should be a godsend for processing TeX files. I > have it installed now on my OS X box (but couldn't build the gel > binary) and am looking forward to experimenting with it. lua's pattern matcher can hanle nested {} (syntax: %b{} and such) more clever things can be done with lpeg, bla {bla\{bla} and such if you're up to date you may try mtxrun --script check sometexfile.tex this is a (for the mooment simple) syntax checker i wrote a while ago which shows the principles Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-02-12 15:15 ` Hans Hagen @ 2008-02-12 17:39 ` Aditya Mahajan 2008-02-13 8:39 ` Taco Hoekwater 0 siblings, 1 reply; 24+ messages in thread From: Aditya Mahajan @ 2008-02-12 17:39 UTC (permalink / raw) To: mailing list for ConTeXt users On Tue, 12 Feb 2008, Hans Hagen wrote: > Thomas A. Schmitz wrote: >> Hi Aditya, >> >> now I need to apologize for being so slow to reply: thanks a lot, this >> looks really fascinating! I don't know how many things I've read on >> the web to understand if regexps can handle nested delimiters or not >> (I think the long and short of it was that on some mathematical >> principle it just isn't possible); there is some pretty obscure perl >> stuff that might be able to do it but is highly experimental. If gema >> really can do this, it should be a godsend for processing TeX files. I >> have it installed now on my OS X box (but couldn't build the gel >> binary) and am looking forward to experimenting with it. > > lua's pattern matcher can hanle nested {} (syntax: %b{} and such) > > more clever things can be done with lpeg, bla {bla\{bla} and such > > if you're up to date you may try > > mtxrun --script check sometexfile.tex > > this is a (for the mooment simple) syntax checker i wrote a while ago > which shows the principles I have been looking at different ways to parse TeX syntax since I occassionally do ConTeXt -> LaTeX conversion. Things like gema and regexs are ok for small things: e.g., convert ConTeXt section commands to LaTeX section commnads, convert figures, etc. Gema is better if you also want to convert ConTeXt font commands to LaTeX; since it is easier to write nested conversions. However, both fail miserably if you want to convert things like ConTeXt multi-line math statements to LaTeX. For that a real parser is needed. I have looked at Parsec (and Pandoc project) in Haskell, but have not made too much progress there. Maybe lpeg is an easier to understand parser. (But I sometimes get the feeling that the whole thing will be easier in TeX, since TeX already parses itself :) 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: {{ double braces }} 2008-02-12 17:39 ` Aditya Mahajan @ 2008-02-13 8:39 ` Taco Hoekwater 2008-02-13 9:31 ` luigi scarso 0 siblings, 1 reply; 24+ messages in thread From: Taco Hoekwater @ 2008-02-13 8:39 UTC (permalink / raw) To: mailing list for ConTeXt users Aditya Mahajan wrote: > I have been looking at different ways to parse TeX syntax since I > occassionally do ConTeXt -> LaTeX conversion. Things like gema and regexs > are ok for small things: e.g., convert ConTeXt section commands to LaTeX > section commnads, convert figures, etc. Gema is better if you also want to > convert ConTeXt font commands to LaTeX; since it is easier to write nested > conversions. However, both fail miserably if you want to convert things > like ConTeXt multi-line math statements to LaTeX. For that a real parser > is needed. I have looked at Parsec (and Pandoc project) in Haskell, but > have not made too much progress there. Maybe lpeg is an easier to > understand parser. (But I sometimes get the feeling that the whole thing > will be easier in TeX, since TeX already parses itself :) This is actualy pretty easy, I did that for a TeX->XML conversion once. You have to redefine each and every command and make all special chars like $ and _ \active, but it is in fact pretty easy and fairly reliable. I would not do it like that again, these days I would use lpeg, but it was not nearly as complicated to do it in tex macros as I had anticipated. Best wishes, Taco ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-02-13 8:39 ` Taco Hoekwater @ 2008-02-13 9:31 ` luigi scarso 2008-02-13 10:21 ` Taco Hoekwater 0 siblings, 1 reply; 24+ messages in thread From: luigi scarso @ 2008-02-13 9:31 UTC (permalink / raw) To: mailing list for ConTeXt users > I would not do it like that again, these days I would use lpeg, but > it was not nearly as complicated to do it in tex macros as I had > anticipated. A bit off-topic: suppose that I , while I'm making format , I need to trace macro definitions (\edef,\xdef,\def,\let and eventually alias like \let\define\def, so also \define too,...) This can be do only hacking web source , or not ? -- luigi it's new . it's powerful . it's luatex . http://www.luatex.org ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-02-13 9:31 ` luigi scarso @ 2008-02-13 10:21 ` Taco Hoekwater 2008-02-13 10:38 ` luigi scarso 0 siblings, 1 reply; 24+ messages in thread From: Taco Hoekwater @ 2008-02-13 10:21 UTC (permalink / raw) To: mailing list for ConTeXt users luigi scarso wrote: >> I would not do it like that again, these days I would use lpeg, but >> it was not nearly as complicated to do it in tex macros as I had >> anticipated. > A bit off-topic: > suppose that I , while I'm making format , I need to trace macro definitions > (\edef,\xdef,\def,\let and eventually alias like \let\define\def, so > also \define too,...) > This can be do only hacking web source , or not ? If you set \tracingassigns=1 \tracingrestores=1 you will get a dump in the log of all assignments (and that includes definitions) as well as restores. You will not get the full definitions of macros though, just the first 32 tokens. If you want the full definition, you really have to hack the web source. Best wishes, Taco ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-02-13 10:21 ` Taco Hoekwater @ 2008-02-13 10:38 ` luigi scarso 0 siblings, 0 replies; 24+ messages in thread From: luigi scarso @ 2008-02-13 10:38 UTC (permalink / raw) To: mailing list for ConTeXt users > > A bit off-topic: > > suppose that I , while I'm making format , I need to trace macro definitions > > (\edef,\xdef,\def,\let and eventually alias like \let\define\def, so > > also \define too,...) > > This can be do only hacking web source , or not ? > > If you set > \tracingassigns=1 > \tracingrestores=1 > you will get a dump in the log of all assignments (and that > includes definitions) as well as restores. > > You will not get the full definitions of macros though, just the > first 32 tokens. If you want the full definition, you really have > to hack the web source. ok, I suppose it. Hacking the web source should be also permit to trace primitive of luatex . Thank you very much -- luigi it's new . it's powerful . it's luatex . http://www.luatex.org ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-01-23 22:17 ` Thomas A. Schmitz 2008-01-23 23:19 ` Aditya Mahajan @ 2008-01-26 10:52 ` Taco Hoekwater 2008-01-26 11:41 ` Taco Hoekwater 1 sibling, 1 reply; 24+ messages in thread From: Taco Hoekwater @ 2008-01-26 10:52 UTC (permalink / raw) To: mailing list for ConTeXt users Thomas A. Schmitz wrote: > > You could also use a nice scripting language like ... lua!! lua has > support for "balanced strings," so no nesting trickery is needed, > see http://www.lua.org/pil/20.2.html > (scroll to the bottom of the page). Or you could try and nag Hans > into giving a nice tutorial on the lua lpeg library at Bohinj! :-) Even in bare lua, it is very easy to match balanced braces: local data = "\\footnote{x{y}z}" local match = "\\footnote%s%b{}" local i = 0 while true do i,j = string.find(data, match, i+1) if i == nil then break end print(string.sub(data, i, j)) end with lpeg, the code looks a bit harder, but is still short and relatively shortforward: local matchtable = { "TEXT", SP = lpeg.S" \n\t"^0, BODY = lpeg.P{ "{" * ((1 - lpeg.S"{}") + lpeg.V(1))^0 * "}" }, FOOTNOTE = lpeg.P"\\footnote" * lpeg.V"SP" * lpeg.V"BODY" / print, TEXT = (lpeg.V"FOOTNOTE" + 1)^0 * -1, } lpeg.match(matchtable, data) Best wishes, Taco ___________________________________________________________________________________ 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] 24+ messages in thread
* Re: {{ double braces }} 2008-01-26 10:52 ` Taco Hoekwater @ 2008-01-26 11:41 ` Taco Hoekwater 0 siblings, 0 replies; 24+ messages in thread From: Taco Hoekwater @ 2008-01-26 11:41 UTC (permalink / raw) To: Taco Hoekwater; +Cc: mailing list for ConTeXt users Taco Hoekwater wrote: > > with lpeg, the code looks a bit harder, but is still short and > relatively shortforward: Here is a smarter lpeg that takes care of embedded \{ as well: local P, S, V = lpeg.P, lpeg.S, lpeg.V local matchtable = { "TEXT", TEXT = (V("FOOTNOTE") + 1)^0 * -1, SP = S(" \n\t")^0, BODY = "{"*(P("\\{")+P("\\}")+(1 - S("{}"))+V("BODY"))^0*"}", FOOTNOTE = "\\footnote" * V("SP") * V("BODY") / print, } lpeg.match(matchtable, data) Quick explanation: the symbol + is alternation, * is concatenation, - is exclusion, ^ is a repeat modifier, "" and P("") match strings, numbers match bytes, S("") matches byte sets. the "matchtable" describes the input data. In there, matchtable[1] points to the "top" rule, which is "TEXT". The other key-value pairs in the table say roughly this: TEXT = an optional sequence [^0] of either footnote items [V("FOOTNOTE")] or non-footnote bytes [1], until the end of the data is reached [-1] FOOTNOTE = the string '\footnote', followed by optional space, followed by the footnote body. SP = zero or more occurrences of a space, tab, or newline byte BODY = a left brace, followed by an optional sequence of four possible things: 1. the string "\{" [P("\\{")] 2. the string "\}" [P("\\}")] 3. a byte that is not "{" nor "}" [(1 - S("{}"))] 4. a recursively included braced body [V("BODY")], followed by a right brace. The [/print] runs the print() command on each successful FOOTNOTE match. Best wishes, Taco ___________________________________________________________________________________ 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] 24+ messages in thread
end of thread, other threads:[~2008-02-13 10:38 UTC | newest] Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-01-21 14:45 {{ double braces }} Steffen Wolfrum 2008-01-21 15:02 ` Mikael Persson 2008-01-21 15:53 ` Steffen Wolfrum 2008-01-23 20:49 ` Peter Münster 2008-01-23 21:50 ` Peter Münster 2008-01-23 22:17 ` Thomas A. Schmitz 2008-01-23 23:19 ` Aditya Mahajan 2008-01-26 10:11 ` Thomas A. Schmitz 2008-02-06 7:01 ` Aditya Mahajan 2008-02-06 9:11 ` Steffen Wolfrum 2008-02-06 16:36 ` Aditya Mahajan 2008-02-06 19:20 ` Hans van der Meer 2008-02-06 20:01 ` Steffen Wolfrum 2008-02-06 20:16 ` Hans van der Meer 2008-02-06 20:17 ` Otared Kavian 2008-02-12 15:09 ` Thomas A. Schmitz 2008-02-12 15:15 ` Hans Hagen 2008-02-12 17:39 ` Aditya Mahajan 2008-02-13 8:39 ` Taco Hoekwater 2008-02-13 9:31 ` luigi scarso 2008-02-13 10:21 ` Taco Hoekwater 2008-02-13 10:38 ` luigi scarso 2008-01-26 10:52 ` Taco Hoekwater 2008-01-26 11:41 ` Taco Hoekwater
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).