[pmwiki-users] custom markup parameter issue

Patrick R. Michaud pmichaud at pobox.com
Fri Jan 12 05:00:53 CST 2007


On Fri, Jan 12, 2007 at 11:14:51AM +0100, info at hassanein.ch wrote:
> How can I pass a parameter from the markup defintion to a function.
> The following code shows always $1 instead of it's contnet.
> 
> Markup("mymu", "inline", "/_mymu_ (.*?) _mymu_/", myFunc('$1') );
> 
> function myFunc($inp) {
>  // does not prnt $inp, it prints "$1"
>  printf("inp=%s \n", $inp);
> }


If you want to execute a function on a pattern, you need to use the 
/e option on the pattern, and enclose the code to be executed in quotes.
Also, if $1 might contain quotes or backslashes in it, you'll
want to surround it with PSS().  Thus:

    Markup('mymu', 'inline',
      '/_mymu_ (.*?) _mymu_/e',
      "myFunc(PSS('$1'))");

See http://www.pmwiki.org/wiki/PmWiki/CustomMarkup< especially the
section "Define a markup to call a custom function...".

Pm





More information about the pmwiki-users mailing list