[pmwiki-users] Re: Modified (:markup:)
Joachim Durchholz
jo at durchholz.org
Mon Mar 21 11:04:25 CST 2005
Patrick R. Michaud wrote:
> On Mon, Mar 21, 2005 at 08:44:40AM +0100, Joachim Durchholz wrote:
>
>> Patrick R. Michaud wrote:
>>
>>> I agree, but my implementation of [== ... ==] currently breaks in
>>> the face of text containing multiple [==]'s, so I have to either
>>> come up with a much better pattern or go back to the drawing
>>> board.
>>
>> Would a backreference work?
>>
>> \[(=*)[^=](.*?)\1\]
>
> The matching code already uses a backreference and no it doesn't work.
Hmm... it *should* make sure that the same number of opening and closing
equal signs is matched.
>> The (=*) captures the string of =s after the opening [ and stores
>> them in the $1 variable, the [^= makes sure that a non-= is between
>> the brackest-and-equals-signs delimiters (else we'd match stuff
>> like [==] and we don't want that - might be a useful markup for
>> other purposes),
>
> Unfortunately, [==] is already valid markup and it's already being
> used for a variety of purposes. In particular, it can be used to
> prevent Wiki[==]Words, and I've used it to avoid processing something
> that would otherwise be a beginning of line markup. Thus:
>
> [==]** Line beginning with ''asterisks'', avoid Wiki[==]Word.
Ah, so it's the reverse case: the pattern *should* match [==], [====], etc.
> Unfortunately, the regexp above (and various others I've tried)
> sees this as one big escape instead of two small ones, resulting in
>
> ]** Line beginning with ''asterisks'', avoid Wiki[Word.
My first idea would be this regex (spaces inserted for better readability):
\[ (=*?) (.*?) \1 \]
It should eat the least number of equals signs and arbitrary text to
make the match work.
Regards,
Jo
More information about the pmwiki-users
mailing list