Is the pmwiki integration still supported?

0 votes
asked Sep 15, 2023 in Bug by Morphit (160 points)

On the website here:, the link to the cookbook code is not rendered correctly.

The code is available at but didn't work off the bat. I had to make a few changes to get it to work with pmwiki Version 2.3.10 (though I note that Version 2.3.25 is the current latest).

--- pmplantuml_php.txt  2020-02-01 20:07:10.000000000 +0000
+++ pmplantuml.php      2023-09-15 15:06:02.711068260 +0000
@@ -34,22 +34,24 @@
 function doplantuml($str) {
        global $KPV, $KeepToken;

-       $str = preg_replace( "/$KeepToken(\\d+?)$KeepToken/e", '$KPV[$1]', $str);
+       $str = PPRE( "/$KeepToken(\\d+?)$KeepToken/", '$KPV[$1]', $str[0]);
+       // pmwiki can insert vspace when a blank line is present
+       $str = preg_replace( "<<:vspace>>", "", $str);
        $str = preg_replace( "/&gt;/", ">", $str);
        $str = preg_replace( "/&lt;/", "<", $str);

-       $url = "";
+       $url = "";
        $url .= encodep($str);
        return Keep('<img src='.$url.' />');

-       '/(@start\w+.*?@end\w+)/sexi',
-       'doplantuml("$1")');
+       '/(@start\w+.*?@end\w+)/sxi',
+       "doplantuml");

 function encodep($text) {
-     $data = utf8_encode($text);
+     $data = $text;
      $compressed = gzdeflate($data, 9);
      return encode64($compressed);

 utf8_encode is deprecated as of PHP 8.2.0 but their alternatives seem to be plugins to PHP. I'm not clear on why input text should be treated as ISO-8859-1. I tried greek utf8 characters and the rendering seems fine.

The /e modifier has been deprecated but I'm not sure what it did originally. I think it might be to do with how the callback function gets called but my changes seem to work besides needing to erase spurious `<vspace>` tags.

Should these changes be pushed to the website? I'm not that familiar with PHP so it'd be good to have someone else look it over first.



commented Oct 9, 2023 by The-Lu (65,440 points)

Hi M., and all,

Thanks for the remark, I made a proposal on for the doc.

Then it remains a question:


-       'doplantuml("$1")');

is replaced by:

+       "doplantuml");


  • How does work the `doplantuml($str)` function now?


commented Oct 9, 2023 by Morphit (160 points)

Hi Th.,

    I forget exactly why that change was made, but reverting it breaks rendering. The function name appears literally in the page output, nesting incorrectly. According to the documentation here, the last argument to the Markup function can be either the replacement text itself, or a function name. It will callback the named function during the page render with the content of the match as an argument. I'm not sure why the function call was a string before, maybe there was a second evaluation pass that would call the function after insertion that has now gone. The documentation says to use the bare function name "if evaluation is needed", but I don't know exactly what that entails.

I have the patch working on my pmwiki instance and it seems to function well, including multiple diagrams on a page. Actually I've now changed the plantuml endpoint to use SVG, maybe that should be called out as an option.



1 Answer

+1 vote
answered Oct 11, 2023 by The-Lu (65,440 points)

Hi M., 

Thank Tim for the report,

The corresponding page has been updated with these items:


commented Oct 11, 2023 by Morphit (160 points)

I'll continue to use the integration on my wiki so I'll check back if there are any further issues that crop up. All seems good for now though. Thanks for updating the site.