[TW5] PlantUML include

197 views
Skip to first unread message

Chris Lynch

unread,
Jul 30, 2018, 2:18:15 AM7/30/18
to TiddlyWiki

I've been using the plantuml plugins for both TWc and TW5 recently and love it. Picture tiddlers are now replacing boring old text in my tiddlywiki ;-]

Still learning plantuml, but I saw it has a include feature, which helps break large plantuml code blocks into smaller ones by calling included files. I'm assuming include won't work on TW5.

However, it got me thinking that maybe I could transclude some plantuml tiddlers to obtain the same sort of result as the include function.

I took a simple plantuml tiddler with:

[[plantuml class="pretty" output="img" [
@startuml
class Class
@enduml
]]]

and I created a tiddler Class with just:

class Class

and then tried

[[plantuml class="pretty" output="img" [
@startuml
{{Class}}
@enduml
]]]

but got:


which wasn't what I wanted and the error told me I was literally getting {{Class}}, not its trancluded value.


After reading tiddlywiki.com for awhile (and with head spinning a bit, I must admit) I stumbled upon trying:


<$plantuml
source={{Class}}
/>


which worked and gave me encouragement. Then I tried to get fancier so I created a couple more tiddlers, PlantUmlSetup:


skinparam defaultTextAlignment center
skinparam class {
BackgroundColor Azure
ArrowColor Blue
BorderColor Blue
}
skinparam stereotypeCBackgroundColor LightBlue


and AllCode tiddler:


{{PlantUmlSetup}}
{{Class}}


and then tried:


<$plantuml
source={{AllCode}}
/>


which literally gave me:


{{PlantUmlSetup}}
{{Class}}


Deja vu all over again. I'm hopeful a more experienced coder can get me going in the correct direction once again.


Thanks for your time and any help!

Chris

Chris Lynch

unread,
Jul 31, 2018, 2:33:37 AM7/31/18
to tiddl...@googlegroups.com
I fear this may be a case of tldr; combined with me lacking understanding of a pretty basic tiddlywiki concept. I really do appreciate your patience.

I'm trying to replace the output to this call of a plantuml widget
<$plantuml
source="
Class A
Class B
"
/>
by first creating three tiddlers, A:
Class A
B:
Class B
and C:
{{A}}{{B}}
and I then call the widget by using:
<$plantuml
source=
{{C}}
/>
but I get the string "{{A}}{{B}}" rather than what I hoped for "Class A Class B".

As I said, I'm sensing this is a rookie error but if someone can point me in the right direction I would greatly appreciate it.

Once again, thanks for your time and help.

Cheers - Chris

TonyM

unread,
Jul 31, 2018, 4:30:55 AM7/31/18
to TiddlyWiki
Chris,

I will have a look at this later in detail but I recommend you simplify the problem when you cant find the answer.

Try your various alternatives first out side of your  <$plantuml widget.
Perhaps use set or wikify to prepare the value you want to place insided the widget but see the result first
When calling the widget try using the macrocall widget as it is more robust at giving it variables

<$macrocall $name=plantuml text=<<variableormacroresult>> />

Please remind me where to find plantuml

Regards
Tony

Chris Lynch

unread,
Jul 31, 2018, 1:58:03 PM7/31/18
to TiddlyWiki
Hi Tony,

That is great advice and I also think you might have turn on the light bulb.

I had figured out how to generate <<variableormacroresult>> used in your hint, but I didn't appreciate I could call the plantuml macro with the basic macro call syntax. Makes sense now, but I didn't *really* understand that principle or grasp its flexibility.

I'll give it another go tonight. I'm replying now mostly to provide the plantuml plugin links. I'm becoming a fan of plantuml, which is surprising to me since I am a professional visual programmer[https://en.wikipedia.org/wiki/Visual_programming_language]


Cheers and Thanks!

TonyM

unread,
Jul 31, 2018, 8:24:42 PM7/31/18
to TiddlyWiki
Chris,

I am not sure I am answering your question here, but building up an understanding.

I just tried the following with success, however the field version needs a way to indicate new lines to work properly

\define plantuml(source)
[[plantuml[
$source$
]]]
\end
\define my-diagram()
:In Macro: -left-> (LEFT)
:In Macro: -right-> (RIGHT)
:In Macro: -up-> (UP)
:In Macro: -down-> (DOWN)
\end
<$macrocall $name=plantuml source=<<my-diagram>>/>
<$macrocall $name=plantuml source={{!!field-diag}}/
>
<$macrocall $name=plantuml source={{Diagram Tiddler}}/><$plantuml source=<<my-diagram>>/>
<$plantuml source={{!!field-diag}}/>
<$plantuml source={{Diagram Tiddler}}/>

<$plantuml
width="300px"
tooltip="The Real Hunger Games™?"
source="
title Vegan Nutrition
repeat
while (Hungry?) is (Yes)
  :Eat Healthy;
  note right
    No Animal Products
    Certainly No Dairy
  end note
endwhile (No)
repeatwhile (Go To Sleep)
"/>

<$plantuml
width="256px"
output="img"
tooltip="The Real Hunger Games™?"
source="
title Vegan Nutrition
repeat
while (Hungry?) is (Yes)
  :Eat Healthy;
  note right
    No Animal Products
    Certainly No Dairy
  end note
endwhile (No)
repeatwhile (Go To Sleep)
"/>

The last two are great, as if you r-click save image as you can save the image as svg or png and import back into the wiki without needing to be online.

For your posted problem I split the diagram into two tiddlers with two lines each

An the following partially work, with the first line in the first tiddler not treated correctly

<$plantuml source={{Diagram Tiddler 1}}/>
<$plantuml source={{Diagram Tiddler 2}}/>

<$wikify name=one-diag text="{{Diagram Tiddler 1}}{{Diagram Tiddler 2}}">
<$plantuml source=<
<one-diag>>/>

<$plantuml source={{Combined}}/>

<$wikify name=one-diag text="{{Combined}}">
<$plantuml source=<
<one-diag>>/>

Combined Tiddler
{{Diagram Tiddler 1}}{{Diagram Tiddler 2}}

Diagram Tiddler 1

In tid: -left-> (LEFT)In tid: -right-> (RIGHT)

Diagram Tiddler 2

In tid: -up-> (UP)In tid: -down-> (DOWN)

Now I would love to play with generating images from tioddlywiki info, or linking to tiddlers.

Regards
Tony

TonyM

unread,
Jul 31, 2018, 8:26:13 PM7/31/18
to TiddlyWiki
Sorry,

<$plantuml source={{Combined}}/>

above, fails

Regards
Tony

Chris Lynch

unread,
Aug 1, 2018, 12:23:32 AM8/1/18
to TiddlyWiki
Thank you for sharing your exploration, I found it very useful. I can now get what I was after by using this line from one of your examples in my tiddler:
$wikify name=one-diag text="{{Combined}}">
and if I end every tiddler used to create the tiddler Combined, with a hard linebreak [as I read about at https://tiddlywiki.com/#Hard%20Linebreaks%20in%20WikiText]
"""
If I understand your reference to linking to tiddlers correctly, Tobias has this example that I plan on using in the future.
<$link to="plantuml" tooltip="open docs">
[[plantuml width=64 class=pretty [
Employee -up-|> User
Client -up-|> User
Supervisor -up-|> User
Employee --> (Login)
Supervisor --> (Login)
Client ..> (Login) : NO!!!!
Supervisor --> (Create / Delete User): I am god
]]]
</$link>

Cheers - Chris
Reply all
Reply to author
Forward
0 new messages