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

Scott Diegel scottdiegel at gmail.com
Mon Feb 9 12:00:48 CST 2009


I've managed to get the result I want by editing the return value of
MkSopNumTitle based on whether or not "(:sop:)" was found.  I still think it
seems reasonable to allow "Markup()" in a "Markup()".

Scott



On Mon, Feb 9, 2009 at 9:56 AM, Scott Diegel <scottdiegel at gmail.com> wrote:

> Peter, thanks for the reply.  Unfortunately, your method doesn't seem to
> work quite correctly either.  The method you specified (and several
> variations on it that I tried) works for suppressing the "sop" markup on
> pages that don't have "(:sop:)" specified, but it removes all sectioning on
> the pages on which "(:sop:)" is specified.
>
> It still seems to me that the most straightforward and sensible way to do
> this is to allow a "Markup()" call  within a "Markup()" call, but that
> doesn't seem to work.
>
> So I'm still banging my head over this one.
>
> Scott
>
>
>
> On Sat, Feb 7, 2009 at 9:30 AM, Peter Bowers <pbowers at pobox.com> wrote:
>
>> 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
>> solution.
>>
>> 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;
>> return(true);
>> }
>> if (!$MarkupActive) return;
>>
>>        ... /* the rest of the code for MkSopNumTitle */
>> }
>> Markup('sop','>include','/^(!{2,4})(?:\s*)(.*)$/e',
>> "MkSopNumTitle(strlen('$1'),PSS('$2'))");
>> Markup('sopheaders','directives','/\\(:sop:\\)/e',"MkSopNumTitle(false,
>> 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...
>>
>> -Peter
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20090209/f44f09c0/attachment.html 


More information about the pmwiki-users mailing list