Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path:
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
X-Spam-Status: OK 0.007
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'completeness': 0.05; 'python': 0.08; 'command.': 0.09; 'skip:\\ 10': 0.09; 'tags,': 0.09; 'am,': 0.13; 'wrote:': 0.15; 'assertion': 0.16; 'editors,': 0.16; 'files"': 0.16; 'string:': 0.16; 'stripped': 0.16; 'subject:example': 0.16; 'cc:addr:python-list': 0.16; 'mon,': 0.16; 'cheers,': 0.19; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'assume': 0.23; 'breaks': 0.23; 'appear': 0.23; 'invalid': 0.25; 'lee': 0.28; 'message- id:@mail.gmail.com': 0.28; 'anyway.': 0.29; 'cc:addr:python.org': 0.30; 'nested': 0.30; 'least': 0.31; 'break': 0.33; 'closing': 0.33; 'none': 0.35; 'replacement': 0.35; 'uses': 0.35; 'subject:text': 0.35; 'skip:" 10': 0.36; 'subject:/': 0.36; 'listed': 0.37; 'but': 0.37; 'using': 0.37; 'received:google.com': 0.38; 'not,': 0.38; 'received:209.85.161': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'should': 0.39; 'except': 0.39; 'received:209': 0.40; 'possibility': 0.40; 'tag': 0.64; 'here': 0.66; 'kept': 0.67; 'exclude': 0.77; 'dialect': 0.84; 'xah': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=IaCBHMwQqAXsll1kcskWDnh3lLZpKLQ0AEDpxniVons=; b=ftQJ7ywRN9b5ZgIR5E/7Bq/RfYifhP+81MJo0Sz1kkTRt5PtcoIIGM1lc6nDoi4RaP X98e7hWQh6kOvfALIjC4etGiy9HkdTc7ScLjBRfqL6FP6rZK33y4W8AXnEID56zd6fO9 h5FDhIKUQU5al8r9gmeb9oIxEd37dTdBHKcts=
MIME-Version: 1.0
In-Reply-To:
References:
From: Ian Kelly
Date: Tue, 5 Jul 2011 13:17:25 -0600
Subject: Re: emacs lisp text processing example (html5 figure/figcaption)
To: Xah Lee
Content-Type: text/plain; charset=ISO-8859-1
Cc: python-list@python.org
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: General discussion list for the Python programming language
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Newsgroups: comp.lang.python
Message-ID:
Lines: 33
NNTP-Posting-Host: 2001:888:2000:d::a6
X-Trace: 1309893476 news.xs4all.nl 21842 [2001:888:2000:d::a6]:38880
X-Complaints-To: abuse@xs4all.nl
Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8851
On Mon, Jul 4, 2011 at 12:36 AM, Xah Lee wrote:
> So, a solution by regex is out.
Actually, none of the complications you listed appear to exclude
regexes. Here's a possible (untested) solution:
((?:\s*)+)
\s*
((?:[^<]|<(?!/p>))+)
\s*
and corresponding replacement string:
\1
\2
I don't know what dialect Emacs uses for regexes; the above is the
Python re dialect. I assume it is translatable. If not, then the
above should at least work with other editors, such as Komodo's
"Find/Replace in Files" command. I kept the line breaks here for
readability, but for completeness they should be stripped out of the
final regex.
The possibility of nested HTML in the caption is allowed for by using
a negative look-ahead assertion to accept any tag except a closing
. It would break if you had nested
tags, but then that would
be invalid html anyway.
Cheers,
Ian