[pmwiki-users] Markup Extension writing

Hans Bracker design at softflow.uk
Tue Feb 10 04:18:24 PST 2026


Yes, sum does work. The MarkupExprPlus recipe definitions of add, sub, 
mul and div don't work with 'strcount'. I can fix it and get the value, 
not the token,  by adding a line of code to top of the function, like 
this, calling MarkupRestore():

function MEP_nums($params) {
   $params = trim(MarkupRestore($params));
   $params = preg_split('/\\s+/', $params);
   $args = array();
   foreach ($params as $p) {
     list($d) = sscanf($p, "%g");
     if (is_numeric($d)) $args[] = $d;
   }
   return $args;
}

Is there another way than rewriting recipes?

Hans


On 10/02/2026 10:44, Petko Yotov wrote:
> This seems to work for me.
>
> I tried your code, and the {(sum)} expression on the Cookbook, with 
> this markup:
>
>   {(sum (strcount are PmWiki.BasicEditing) -6)}
>
> The string "are" appears 16 times in my BasicEditing.
>
> The result is correctly 16 - 6 = 10.
>
> Definition:
> $MarkupExpr['sum'] = 'array_sum($args)';
> $MarkupExpr['strcount'] as below.
>
> Petko
>



More information about the pmwiki-users mailing list