[pmwiki-users] Markup() Abuse Recommendations.

Patrick R. Michaud pmichaud at pobox.com
Mon Oct 23 13:09:53 CDT 2006


On Mon, Oct 23, 2006 at 01:55:34PM -0400, Stirling Westrup wrote:
> Patrick R. Michaud wrote:
> > One thing you could try is to do something similar to the
> > way the InterMap code works, which combines all of the keys into
> > a single pattern to be matched.  For example:
> > 
> >     Markup('acronym', 'inline',
> >       '/\\b(html|xml|http|tcpip|dhcp|smtp|pop)\\b/e',
> >       "Acronym(PSS('$1'))");
> > 
> 
> That was my initial attempt. Alas there is no reliable way to know which
> alternative matched when there are zero-length assertions involved. I
> actually found that one of my test cases needed something like this:
> 
> Markup
>   ( 'acronym', 'directives'
>   , '/((?:[^\n](?=<p))|(?:[^\n](?=\n<p)))/m'
>   ,"Replacement(PSS('$1'))"
>   );
> 
> Where $1 ends up having the same contents for two different branches of
> the regex, but the replacements are different. 

Why would you be matching against <p ?  Is that to try to
match against paragraphs?  If so, that doesn't seem at all useful
or important at the 'directives' stage of processing, since paragraph
tags aren't added until the 'block' stage.

If this is to be matching something else, I'm totally confused.

And if it's only one or a few cases that result in the need for
testing zero-length assertions, then it might be worthwhile
to create special rules only for those, and combine the rest
into a single rule.

Pm




More information about the pmwiki-users mailing list