[pmwiki-users] Markup Extension writing
Peter Kay
pkay42 at gmail.com
Tue Feb 10 06:01:49 PST 2026
I seem to recall doing something like this with a recursive call. It's
obviously resource intense if you get a huge amount of traffic but works
fine. I had a rough working recipe before other parts of life took me away.
I can look for what I did if it might help.
--Peter Kay
On Tue, Feb 10, 2026, 7:20 a.m. Hans Bracker <design at softflow.uk> wrote:
> 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
> >
>
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20260210/60d8e4fb/attachment.html>
More information about the pmwiki-users
mailing list