[pmwiki-devel] Markup rule evaluation sequence

John Rankin john.rankin at affinity.co.nz
Mon May 26 17:21:17 CDT 2008


On Friday, 23 May 2008 5:24 PM, Patrick R. Michaud <pmichaud at pobox.com> wrote:
>On Fri, May 23, 2008 at 08:40:45AM +1200, john.rankin at affinity.co.nz wrote:
>><snip>
>
>But if you're in a situation where it's possible that rule1
>doesn't even exist (as opposed to being "disabled"), then
>we can still handle it.  The code for defining rule2 looks
>like:
>
>    Markup('rule1', '>links');
>    Markup('rule2', '>rule1', "pattern2", "replacement2");
>
>If rule1 already exists, then the first call to Markup() here won't
>really impact.  If rule1 doesn't exist, then a "dummy rule" is
>created for rule1 to simply hold its place in the sequence and
>then rule2 is created relative to that.

Ah! That's the trick I need. Thank you.
>
><snip>
>
>And, a recipe can always define its own inter-rule markers that
>can serve as sequence anchors for other rules:
>
>    Markup('rulemarker', '>links');
>    Markup('rule1', '<rulemarker', "pattern1", "replacement1");
>    Markup('rule2', '>rulemarker', "pattern2", "replacement2");
>
>Here we're guaranteed that rule2 will always come after the 'links'
>marker, and after rule1 if it happens to exist.

I assume that because rulemarker is defined *after* 
  Markup('block','>links');
that rulemarker and rule2 also evaluate before block
and rule1 evaluates after links... How do I tell that
rule2 will evaluate before block and rule 1 will evaluate
after links? Or is it just a matter of "suck it and see"?

>
>> What I'd like to do is
>> have some permanent foundations on which to pin possibly
>> temporary markup rules. 
>
>The existing rule sequence markers are intended to be the "permanent
>foundations", and recipes are intended to be able to build from
>those.  They can always add their own placeholders, or supply
>their idea of what a rule's sequence would be if it doesn't
>already exist.

I think I'm just trying to insert too many new rules into
the interstices of the base foundations and getting myself
into trouble.
>
>A recipe can also check to see if a rule exists by using
>things like $MarkupTable['rule1'].
>
>> I also find that things break when a
>> rule changes its location in the evaluation order, affecting any
>> rules on which it depends. For example, this happened to me
>> when one of the core PmWiki rules moved between 2.1 and 2.2.
>
>...and that's probably why it happened as part of a beta and
>not as part of 2.1.  :-)

Sure thing. I see it as my coding error in creating a dependency
on a low level markup rule rather than building with the base
foundations.
>
>Hope this helps!

Yes it does -- I think I need to go back and review my markup
rule tactics to use the foundations more systematically.
>
>Pm
>


-- 
John Rankin
Affinity Limited
T 64 4 495 3737
F 64 4 473 7991
021 RANKIN
john.rankin at affinity.co.nz
www.affinity.co.nz





More information about the pmwiki-devel mailing list