On the website here: https://plantuml.com/pmwiki, the link to the cookbook code is not rendered correctly.
The code is available at https://plantuml.com/pmplantuml_php.txt 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( "/>/", ">", $str);
$str = preg_replace( "/</", "<", $str);
- $url = "http://www.plantuml.com/plantuml/img/";
+ $url = "http://www.plantuml.com/plantuml/png/";
$url .= encodep($str);
return Keep('<img src='.$url.' />');
}
Markup('plantuml',
'fulltext',
- '/(@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.
Cheers,
Tim