Monospace String as Macro Parameter

0 votes
asked May 26, 2018 in Question / help by tomschi
I'm working on an activity diagram and wanted to used monospace font for some elements. In combination with macros I've encountered behavior that is at least surprising to me:

!define TT(x) ""x""
!define E(stmt) :stmt;

'E(""does not work"")
'E(TT(does not work))
E(works fine)

The last line without monospace formatting works fine, but the first two result in errors. Is that to be expected or a problem/bug in PlantUML?

1 Answer

0 votes
answered May 26, 2018 by plantuml (298,440 points)
 
Best answer

Double quotes (and simple quotes) are also used by macro to delimitate argument, so that's why it does not work in your case.

You can turn around by adding simple quote like this:

@startuml
!define TT(x) ""x""
!define E(stmt) :stmt;

E("Double Quote are ignored here, usefull in that case :-)")
E('Simple Quote are ignored here, usefull in that case :-)')
E(work fine1)
E('""work fine2""')
E('TT(work fine3)')
@enduml

http://www.plantuml.com/plantuml/uml/dSux3i8m3CRnlQVuyD96WW7OojA17W2H2mJgqeWyK1wYnuTqA3kJfR_yizp5f4BArbIRWKVj658sim3HJBIsled99e6sZ5DLzGsTVRuPnYNxn521eH_E1numSU0jSkGn6mFja2QLS5UHqUu4YI-khzg-_i1rmMyVdYXVxPTJH6iu4DLBa_AtTIogOpTaQpu0

commented May 26, 2018 by tomschi
Thanks for shedding some light on that matter.

However, if I wanted to display only a part of the text in monospace this will not work, right?

E(does not work '""fine""')

gives me some errors, so i has to be the full argument, not parts of it. Will take // italics // now...
commented May 26, 2018 by plantuml (298,440 points)
You can do:
E('does not work ""fine""')
...