Newer
Older
labs / tiddlers / system / macros / $__ou_macros_pudiagram.tid
tags: $:/tags/Macro
title: $:/ou/macros/pudiagram
type: text/vnd.tiddlywiki

\define pudiagram(pucode, codeHeader:"PlantUML code:")
[[plantuml[$pucode$]]]
$codeHeader$
[[plantuml 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:

```
<<pudiagram
"""
@startuml
a -> b: stuff
@enduml
"""
>>
```

Note the triple-double quotes.  These are necessary to handle speech marks 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 a second string parameter:

```
<<pudiagram 
"""
@startuml
a -> b: stuff
@enduml
"""
"New heading goes here:"
>>
```

Produces:

<<pudiagram 
"""
@startuml
a -> b: stuff
@enduml
"""
"New heading goes here:"
>>