[pmwiki-users] Markup Extension writing - DFaure

Peter Kay pkay42 at gmail.com
Tue Feb 10 09:28:14 PST 2026


It is much safer to avoid eval() if you can get around it

On Tue, Feb 10, 2026, 10:15 a.m. Hans Bracker <design at softflow.uk> wrote:

> I am using the latest MarkupExprPlus.
>
> Trying to write well behaving markup expressions I've now learned this:
>
> 1. My strcount Mx is okay (don't know if it is good), but the result is
> in a keep token.
> 2. For a calculating Mx I need to avoid using $params and avoid using
> $argp, because both times the value is not getting in, but only the
> token string.
> 3. Using $args is okay and the value from an embedded strcount Mx is
> getting processed.
>
> An example for a working multiplication Mx, which can take a multiple of
> args:
>
> // (multi num1 num2 ...) for multiplying numbers
> $MarkupExpr['multi'] = 'ME_Multi($args)';
> function ME_Multi($args) {
>    $a = array();
>    foreach ($args as $i => $v)
>        $a[$i] = floatval($v);
>    $x = 1;
>    foreach ($a as $i => $v)
>        $x = $x * $v;
>    return $x;
> }
>
> 4. This does not use PHP eval(). Many other calc Mxs do. I imagine it is
> better to avoid eval() (?)
>
> 5. To work with numbers  which use decimal comma instead of dot, this
> needs to  be rewritten to remove thousands dots and convert commas to
> dots. But that is a different topic!
>
> Hans
>
> On 10/02/2026 13:18, Petko Yotov wrote:
> > On 10/02/2026 13:18, Hans Bracker wrote:
> >> Is there another way than rewriting recipes?
> >
> > I don't know.
> >
> > MarkupExprPlus seems to disable the core markup expressions and add
> > its own full replacement.
> >
> > It processes not only add/sub/mul/div but all core markup expressions,
> > and any custom ones you may add.
> >
> > See if the problem appears with the latest version of MX+, and maybe
> > DFaure can reply better than me.
> >
> > 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/dc74a69c/attachment.html>


More information about the pmwiki-users mailing list