🧩
New! Render PlantUML diagrams directly inside GitHub with our official browser extension — No server. No tokens. No tracking. Zero permissions but clipboard. — Try it out and let us know what you think!

PmWiki integration

Description

This recipe uses PlantUML to produce UML diagrams inside PmWiki.

The syntax is described on the PlantUML website.

Images are generated by the online service http://www.plantuml.com.

Installation

Download pmplantuml_php.txt (to rename pmplantuml.php) and copy if into your cookbook directory (e.g. /.../pmwiki/cookbook) with the correct name pmplantuml.php.

Include the following line in your local/config.php :

include_once("$FarmD/cookbook/pmplantuml.php");

Usage

You can use standard @startuml and @enduml keywords into your page:

The images are generated automatically:

Patch of pmplantuml.php

Here is a patch proposed on QA-18233 (for pmwiki version 2.3.10 ):

--- 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);
 }