How can I add special characters '###' to a label in activity diagrams?

0 votes
asked Aug 11 in Question / help by Gil
Hi,

I am using a multiline labels like this

1.

How can I add special characters '###' (sharps) to a label in activity diagrams?

2.

I am using the syntax in the example below to make the multi-line label indented so that the UML code looks clearer by indentation.

Any shorter or more correct trick that I can use for this?

(

The following looks bad in the nested conditions...:

:Some multiline label Some multiline label Some multiline label Some multiline label
label Some multiline label Some multiline label Some multiline label  Some multiline label;

)

@startuml

start

if (condition_1 ?) then (YES)
  if (condition_2 ?) then (YES)
    if (condition_3 ?) then (YES)
      !$s = "Some multiline label Some multiline label Some multiline label Some multiline label\n" + \
                "### label Some multiline label Some multiline label Some multiline label  Some multiline label"
      :$s;
      :bla;
    endif
  endif
endif
stop

@enduml

1 Answer

0 votes
answered Aug 11 by The-Lu (49,760 points)
edited Aug 15 by The-Lu

Hello G.,

  1. You can escape this by `~`, see Creole doc page.
  2. For the 2nd point, what indentation do you want to keep?

Here is an example:

@startuml
start
if (condition_1 ?) then (YES)
  if (condition_2 ?) then (YES)
    if (condition_3 ?) then (YES)
      :Some multiline label Some multiline label Some multiline label Some multiline label
      ~### label Some multiline label Some multiline label Some multiline label  Some multiline label;
      :bla;
    endif
  endif
endif
stop
@enduml

Regards.

commented Aug 14 by Gil

Thanks The-Lu !

1.

It indeed works to escape ###, but I was hoping it to be a generic escape char for any special characters. So now I have the same problem to escape "=".

Any idea how to escape '=' ?

E.g. I want to print a label like this:

:==> This is my label;

the leading "==" are not printed...

2.

The indentation I was meaning is e.g. :

I want to print a multiline label like this:

if (CONDITION_1 is TRUE ?)

  if (CONDITION_2 is TRUE ?)

    :First row of the label

    Second row of the label;

  endif

endif

But in the second line - I want to avoid the leading spaces to be printed,

On the other hand, I don't want to write it like the below because it is less readable:

if (CONDITION_1 is TRUE ?)

  if (CONDITION_2 is TRUE ?)

    :First row of the label

Second row of the label;

  endif

endif

commented Aug 15 by The-Lu (49,760 points)

Hello G., and all,

1. For general escaping, you can use <code>, as:

@startuml
:<code>
==> This is my label
</code>;
@enduml

2. Your two codes generate (on v. 1.2022.7+) the same expected output:

CodeOutput
@startuml
if (CONDITION_1 is TRUE ?)
  if (CONDITION_2 is TRUE ?)
    :First row of the label
    Second row of the label;
  endif
endif
@enduml
@startuml
if (CONDITION_1 is TRUE ?)
  if (CONDITION_2 is TRUE ?)
    :First row of the label
Second row of the label;
  endif
endif
@enduml

Regards.

commented Aug 15 by The-Lu (49,760 points)

For 1. another workaround is to put a space just before the special char, as:

@startuml
: == This is my label
 ==> This is a label
 ==> This is a label
 ## This is my label;
@enduml

Enjoy.

...