Summary: Talk page for MarkupExprPlus.
Maintainer: Dfaure
Users: +8 (View / Edit)

This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.

in some cases, the return value (later fed into $terms/$code in pmwiki.php) evaluates to empty which leads to Parse error: syntax error, unexpected token ")" in /data0/www/php/pmwiki/pmwiki.php(301) : eval()'d code. i propose to make pmwiki.php a little more robust by inserting
 if (empty($code)) return false;
 return @eval("return( $code );");

Agreed, added for 2.3.33, thanks! --Petko

Line 56 (the definition of the if markup expression) makes for weird behavior when one of the arguments 2 or 3 are 0; i.e., it doesn't properly return 0, but instead returns empty string!

I fixed it by changing to this:

   'if' => '$args[0] ? $args[1] : $args[2]',

Said Achmiz November 25, 2017, at 01:07 AM

I've noticed some strange rendering of pages on the MarkupExprPlus page under the wikiword section.


I've had similar renderings in the last several day. Does anyone know what's causing it? DannyB 29-Apr-2014

Yes, sorry about this. The recent changes in PmWiki to work with new PHP 5.5 installations appear to have broken some of the functions of this recipe. I'll try to find some time to review it. --Petko April 29, 2014, at 03:09 PM

Thanks. These changes in PHP are really creating a lot of headaches. DannyB 30-Apr-2014

Version 2014-12-04 have fixed PHP 5.5 compatibility. --Petko May 09, 2015, at 01:17 AM

Along with the rev and rot13 functions an md5 function could be useful. Maybe keep it in mind for a future version of the recipe.

Blues September 18, 2007, at 04:29 AM

For now, you only need in your configuration file:
$MarkupExpr['md5'] = 'md5($args[0])';
Dfaure September 18, 2007, at 08:09 AM

Is there a reason these expressions are called through a separate markup function rather than through the built-in $MarkupExpr array? I'd like to be able to use one or two of these without having to install the whole recipe. BenStallings

The "separate markup function" is only a drop-in replacement of the original one defined in the core which hasn't been tailored to handle complex expressions. Feel free to "extract" the expressions token definitions you need and make your own (sub)recipe with them --Dfaure March 03, 2008, at 03:35 PM

hi, is it possible to cut a Variable by String? for example: My Pagename "$Name" is Word1Word3. Now I´m searching for a solution to cut the variable infront of the String "Word3". My Problem - the Variable "$Name" can changed to "Word200"..., but the string "Word3" is set. Hope you can help me. Hendrik June 17, 2008, at 07:23 AM

This is a perfect job for a regular-expressions replacement such as: {(reg_replace '/(?:.*)(Word3)/' '$1' '{$Name}')} --Dfaure June 18, 2008, at 06:55 AM

Dfaure, Could you add a mathematical operator to determine if a number is even or odd? It appears to be a simple PHP operation, but I'm no PHP programmer! I'm trying to create a Pagelist template with alternating (Zebra) background colors. The Pagelist variable, {$$PageCount}, already provides the iteration number. If an even/odd boolean function existed, then conditional markup could be used to alternate the colors. --CRAjr July 17, 2008, at 8:37 AM

Have you looked at FormattingTables? The method for zebra tables works with simple table markup, even if you use it in a pagelist template. HansB
The function already exists, "mod" (modulo, remainder). You can use {(mod {$$PageCount} 2)} to print alternatively "0" or "1", {(mod {$$PageCount} 3)} to print "0", "1" or "2" etc. --Petko
Excellent! You guys are the best! Hans, I have successfully created zebra tables in the past, and that's what I first attempted. But, I was unable to get it to work in a pagelist. I'll have to go back and try again. Meanwhile, Petko, your solution works perfectly. -- CRAjr

I am trying to add Gravatar to Fox Comments, for this a conditional expression is needed along with MD5. The problem is that the (md5 {$$email}) in the else condition appears as-is in the output due to the keep function. Is there any facility to allow expressions inside the arguments to the if, or any better implementation? My code is:

{$$(if (test equal '{$$email}' '') ''
' {$$email})&size=20&d=identicon&foo.png' )}

--Kartik Feb 4, 2009

Talk page for the MarkupExprPlus recipe (users).