[pmwiki-users] In code, how to conditionally prevent Markup processing on subsequent run due to PRR
Peter Bowers
pbowers at pobox.com
Wed Jan 12 01:03:37 CST 2011
If you need other rules to continue to act on your markup (i.e.,
Keep() won't work) I *think* this will work...
===(snip)===
Markup('realaction', 'certainorder', '/mypattern/e', 'RealAction("$0")');
Markup('rulestopper', '>realaction', '/\(:rulestopper:\)/e', 'RuleStopper()');
function RealAction($str)
{
global $MyActionStatus; // 0=first time called, 1=still active, 2=inactive
SDV($MyActionStatus, 0);
if ($MyActionStatus == 2) return ($str); // don't change anything
// do other stuff setting $rtn
if ($MyActionStatus == 0) {
$MyActionStatus = 1;
return $rtn.'(:rulestopper:)'; // make sure RuleStopper() will be called
}
return $rtn;
}
function RuleStopper()
{
global $MyActionStatus;
$MyActionStatus = 2;
return ''; // get rid of the (:rulestopper:) markup
}
===(snip)===
Of course, depending on what your RealAction() is doing and returning
it may be appropriate to append some arbitrary markup, so that may not
be a good solution...
Also (caveat) this is email-created-software and so it may cause
global hunger, syntax errors, nuclear war, and other negative side
effects (including not working) when used in real life... :-)
It would be nice if PRR() had some global value that it incremented to
indicate how many times the rules have been restarted -- then a simple
static variable would solve it. But it's not a common need, so I'm
not sure if it's worth a PITS entry or not...
Hope that helps.
-Peter
On Tue, Jan 11, 2011 at 6:22 PM, Chris Cox <ccox at endlessnow.com> wrote:
> How do I stop reprocessing due to PRR? I have php code that does some
> Markup replacement and I want to make sure that it doesn't get run again
> if PRR is called by some other markup.
>
>
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
>
More information about the pmwiki-users
mailing list