<div class="gmail_quote">On Fri, Feb 6, 2009 at 8:33 PM, Scott Diegel <span dir="ltr"><<a href="mailto:scottdiegel@gmail.com">scottdiegel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
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.<div><div>
<div><div></div></div></div></div></blockquote><div>... <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div><div><div>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.</div>
<div><br></div><div><span style="font-family: 'courier new',monospace;">/*</span></div><div><span style="font-family: 'courier new',monospace;">function SOPheaders(){</span></div>
<div><span style="white-space: pre;"><span style="font-family: 'courier new',monospace;">        </span></span><span style="font-family: 'courier new',monospace;">Markup('sop','>include','/^(!{2,4})(?:\s*)(.*)$/e', "MkSopNumTitle(strlen('$1'),PSS('$2'))");</span></div>
<div><span style="white-space: pre;"><span style="font-family: 'courier new',monospace;">        </span></span><span style="font-family: 'courier new',monospace;">}</span></div>
<div><span style="font-family: 'courier new',monospace;">Markup('sopheaders','directives','/\\(:sop:\\)/e',"SOPheaders()");</span></div><div><span style="font-family: 'courier new',monospace;">*/</span></div>
<br></div><div>Is this the right approach? Is there another approach I can try?</div><div></div></div></div></blockquote><div><br>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.<br>
<br>If, on the other hand, it's not working then this is what I would suggest:<br><br><div><span style="font-family: 'courier new',monospace;">function </span><span style="font-family: 'courier new',monospace;">MkSopNumTitle</span><span style="font-family: 'courier new',monospace;">($arg1, $arg2, $MakeMeActive=false){</span></div>
<div><span style="white-space: pre;"><span style="font-family: 'courier new',monospace;">        static $MarkupActive = false;<br><br> if ($MakeMeActive) {<br> $MarkupActive = true;<br> return(true);<br>
}<br> if (!$MarkupActive) return;<br><br></span></span><span style="font-family: 'courier new',monospace;"></span></div>
<div><span style="white-space: pre;"><span style="font-family: 'courier new',monospace;"></span></span><span style="font-family: 'courier new',monospace;"></span> ... /* the rest of the code for MkSopNumTitle */<br>
}<br></div>
<div><div><span style="white-space: pre;"><span style="font-family: 'courier new',monospace;"></span></span><span style="font-family: 'courier new',monospace;">Markup('sop','>include','/^(!{2,4})(?:\s*)(.*)$/e', "MkSopNumTitle(strlen('$1'),PSS('$2'))");</span></div>
<div><span style="white-space: pre;"><span style="font-family: 'courier new',monospace;"></span></span></div><span style="font-family: 'courier new',monospace;">Markup('sopheaders','directives','/\\(:sop:\\)/e',"</span><span style="font-family: 'courier new',monospace;">MkSopNumTitle(false, false, true)</span><span style="font-family: 'courier new',monospace;">");</span></div>
<br>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...<br><br>-Peter <br></div></div>