[pmwiki-users] Markup Extension writing - DFaure
Hans Bracker
design at softflow.uk
Tue Feb 10 07:13:50 PST 2026
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
>
More information about the pmwiki-users
mailing list