From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/29805 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: regexp for matching entire footnotes Date: Sun, 30 Jul 2006 21:28:44 +0200 Message-ID: <44CD086C.5000606@wxs.nl> References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1154287750 32054 80.91.229.2 (30 Jul 2006 19:29:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 30 Jul 2006 19:29:10 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Sun Jul 30 21:29:08 2006 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1G7Gy7-0004Mc-3i for gctc-ntg-context-518@m.gmane.org; Sun, 30 Jul 2006 21:28:55 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id AE9621FE0F; Sun, 30 Jul 2006 21:28:53 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 24866-04-4; Sun, 30 Jul 2006 21:28:46 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id C78FA1FE1D; Sun, 30 Jul 2006 21:28:45 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id C0A201FE1D for ; Sun, 30 Jul 2006 21:28:42 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 24866-04-3 for ; Sun, 30 Jul 2006 21:28:40 +0200 (CEST) Original-Received: from mail.pragma-ade.net (dsl-083-247-100-017.solcon.nl [83.247.100.17]) by ronja.ntg.nl (Postfix) with SMTP id 893C71FE0F for ; Sun, 30 Jul 2006 21:28:40 +0200 (CEST) Original-Received: from [10.100.1.102] (unverified [10.100.1.102]) by controller-1 (SurgeMail 3.5b3) with ESMTP id 29894 for ; Sun, 30 Jul 2006 21:28:40 +0200 User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) Original-To: mailing list for ConTeXt users In-Reply-To: X-Server: High Performance Mail Server - http://surgemail.com r=-274017400 X-Authenticated-User: hagen@controller-1 X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:29805 Archived-At: Sanjoy Mahajan wrote: >> I have to find (highlight) footnotes with the entire footnote being >> marked/highlighted. The problems are the (potentially) nested pairs >> of curled brackets (like for \index, \emphasize etc etc) ... >> > > I'm not sure what you mean by marking or highlighting the footnote. > Do you mean in the printed document, or in the source file so that you > can find and change them in some way? > > >> Constructing a regexp for this is far beyond what I can write, >> > > In the Chomsky hierarchy of grammars, regular languages, which are > recognized by regexps, are below context-free grammars (CFGs). > Compared to regular languages, CFGs add a stack. And you need a stack > to parse nested delimiters, otherwise you can't tell whether a closing > brace closes the first opening brace. So no regexp can do what you > hope for. > lua reg exps have a way do handle nested () {} [] > You could: > > 1. Use emacs (or your favorite editor) to substitute \myfootnote for > \footnote, and do some ConTeXt setup magic to make \myfootnote be > just like \footnote except that it highlights. > > 2. Use Emacs, which can find balanced braces, to make a keyboard macro > (start defining it with "C-x ("). Then: > a. search for \footnote. Now the point will be between the 'e' > and the opening '{'. > b. C-@ to set the mark. > c. C-M-f ("alt-ctrl-f" to run 'forward-sexp') to move to the > closing brace. Now you'll have highlighted the {...} stuff of > the \footnote. > d. C-x ) to end the keyboard macro definition. > > Then you can use C-x e to go to and highlight the next footnote > material. > > But I'm not sure either is what you're trying to do? > a multistep approach is possible: - mark each { } with something that reflects nesting (say <{1> <{2> <}2> <}1> etc - you can now distinguish matching pairs and take some action - afterwards you convert the <..> things back to { } (at least that is how i did such thing until now in e.g. ruby) 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 -----------------------------------------------------------------