tags: $:/tags/Macro title: $:/ou/macros/pudiagram type: text/vnd.tiddlywiki \define pudiagram(pucode, codeHeader:"PlantUML code:") [[plantuml[$pucode$]]] <p>$codeHeader$</p> [[plantuml class="plaintext hljs code" edit="false" output="src" [$pucode$]]] \end A macro for rendering both a PlantUML diagram and the code for the diagram from a single code block. Usage: ```plaintext <<pudiagram """ @startuml a -> b: stuff @enduml """ >> ``` Note the triple-double quotes. These are necessary to handle speech marks and stereotypes in the code. Produces: <<pudiagram """ @startuml a -> b: stuff @startuml """ >> If you want to change the heading that appears between the diagram and the code, then use the `codeHeader` parameter: ```plaintext <<pudiagram codeHeader:"New Code Header" """ @startuml a -> b: stuff @enduml """ >> ``` Produces: <<pudiagram codeHeader:"New Code Header" """ @startuml a -> b: stuff @enduml """ >> !! Markdown The Markdown parser is quite fragile and will choke on anything but the simplest diagram. It is also stupidly sensitive to line breaks. Basically, ''use WikiText if you are using this macro''.