[pmwiki-users] Markup() Abuse Recommendations.

Patrick R. Michaud pmichaud at pobox.com
Mon Oct 23 10:10:08 CDT 2006

On Sun, Oct 22, 2006 at 08:11:25PM -0400, Stirling Westrup wrote:
> I have an array of regex keys and their corresponding replacements. I
> can easily imagine it growing to several hundred entries. I need to
> enter each of these into the Markup() function while ensuring that they
> are executed in the order they are given.  Now, I can imagine doing
> something like this:
> $i = 0;
> $last = inline;
> $base = 'MyName:';
> foreach($patterns as $pat => $rep)
>   { $name = $base.$i++;
>     Markup($last,$name,$pat,$rep);
>     $last = ">$name";
>   }
> The question is: is this the best way? 

I don't have a better one off the top of my head.

> [...]
> I'm also not sure that this is the correct way to ensure the ordering I
> need. I fear it will really slowdown the markup engine to have such long
> chains of dependencies, but I don't know of a better way.

Somewhere there has to be a pattern and replacement for
each acronym, which to me does imply that there's a lot of
additional pattern matching taking place.  I don't have any 
immediate ideas for improving this.

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',


More information about the pmwiki-users mailing list