[pmwiki-users] Markup() in a Markup() call, or conditionally loading a recipe

Peter Bowers pbowers at pobox.com
Sat Feb 7 09:30:39 CST 2009

On Fri, Feb 6, 2009 at 8:33 PM, Scott Diegel <scottdiegel at gmail.com> wrote:

> I want a Markup() call to apply only to a given type of page, specifically
> if (:sop:) is included on a wiki page.  The Markup will affect section
> numbering, but I still need the standard section markup to be used.

> Loading the file in which this is defined via config.php results in the
> section formatting being changed for all pages.  I tried the following, and
> checked using ?action=ruleset whether the 'sop' rule was being applied;
> 'sopheaders' is being applied, but 'sop' is not.
> /*
> function SOPheaders(){
>  Markup('sop','>include','/^(!{2,4})(?:\s*)(.*)$/e',
> "MkSopNumTitle(strlen('$1'),PSS('$2'))");
>  }
> Markup('sopheaders','directives','/\\(:sop:\\)/e',"SOPheaders()");
> */
> Is this the right approach?  Is there another approach I can try?

That looks fine to me.  And if SOPheaders is always active but sop only
active on the appropriate pages then that's exactly what you want, right?
My only concern is whether a markup that gets defined *during* markup will
get applied correctly (i.e., will it get put in the right order, etc. -- is
all that done inside the Markup() function or is it done separately in
pmwiki.php after config.php).  I'd say if it works then you've got a great

If, on the other hand, it's not working then this is what I would suggest:

function MkSopNumTitle($arg1, $arg2, $MakeMeActive=false){
 static $MarkupActive = false;

if ($MakeMeActive) {
$MarkupActive = true;
if (!$MarkupActive) return;

       ... /* the rest of the code for MkSopNumTitle */
false, true)");

However, your rule-based solution is superior as long as it actually works.
It's better to not even have a rule to process when you don't need it...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20090207/40cd0314/attachment.html 

More information about the pmwiki-users mailing list