[pmwiki-devel] stripmagic

Patrick R. Michaud pmichaud at pobox.com
Fri Dec 29 10:07:55 CST 2006


On Fri, Dec 29, 2006 at 05:01:13PM +0100, christian.ridderstrom at gmail.com wrote:
> On Fri, 29 Dec 2006, Patrick R. Michaud wrote:
> 
> >Actually, I think the text just needs clarification.
> >
> >   The PSS() function removes the backslashes that are
> >   automatically inserted in front of quotation marks by
> >   the /e option of PHP's preg_replace function.  PSS() is
> >   most commonly used in replacement arguments to Markup(),
> >   when the pattern specifies /e and one or more of the
> >   parenthesized subpatterns could contain a quote or backslash.
> >   ("PSS" stands for "PmWiki Strip Slashes".)
> >
> >Is that any better?
> 
> Yes, much better. I changed the text on the page to this:
> 
> 	The PSS() function removes the backslashes that are
> 	automatically inserted in front of quotation marks by
> 	the /e option of PHP's preg_replace function.  PSS() is
> 	most commonly used in replacement arguments to Markup(),
> 	when the pattern specifies /e and one or more of the
> 	parenthesized subpatterns could contain a quote or backslash.
> 	("PSS" stands for "PmWiki Strip Slashes".)
> 
> 	Example of where PSS() is used with Markup():
> 	-> [@
> 	Markup('includepage', '>if',
> 	       '/\\(:includepage\\s+(\\S.*?):\\)/ei',
> 	       "PRR(IncludePageText(\$pagename, PSS('$1')))");
> 	@]

It might be better if the example were taken from something in
the PmWiki core, or perhaps a simpler example.  Maybe something
like:

    Markup('example', 'directives',
      '/\\(:example\\s(.*?):\\)/e',
      "Keep('<div>'.PSS('$1').'</div>')");

Here we need PSS() around the '$1' because the matched text
could contain quotation marks, and the /e will add backslashes
in front of them.  

Pm



More information about the pmwiki-devel mailing list