How can I workaround numerical <style> wrapper limit?

0 votes
asked May 13, 2024 in Question / help by rtilleryweb (120 points)
edited May 13, 2024 by rtilleryweb

Based on this question, I added style to my arrows using a stereotype. However, this does not appear to work for short arrows:

@startuml
<style>
.a {
  LineThickness 3
  Linecolor red
}
</style>
participant alice
alice -> bob : msg
alice ->x? <<a>> : red
@enduml

PlantUML Server

PlantUML error

To format short arrows, I used the style workaround mentioned for LineStyle in the checked answer of the above question. I also used this for other places where the formatting doesn't work for stereotypes or inline (e.g. certain group format parameters). However, I have run into an issue with this now: After using it in the same diagram for a while, it stops working.

(Note that I am creating rather complicated diagrams. Although I have broken them up, I was asked to provide a single combined diagram as well, which is where this occurs.)

After a couple hundred of these <style></style> changes, things break. (On the PlantUML server, the default size of the render images appears to be being used, so you can't see it there. But you can see it at the bottom of the rendered SVG version.)

@startuml
<style>
.a {
  LineThickness 5
  LineColor green
}
</style>

!procedure $LineSets($num)

  !while $num > 0
    alice -> bob <<a>> : msg

    <style>
      arrow {
      LineThickness 3
      Linecolor red
    }
    </style>

    alice ->x? : red

    <style>
    arrow {
      LineThickness 1
      Linecolor black
    }
    </style>

       !$num = $num - 1
  !endwhile
!endprocedure

$LineSets(300)
@enduml

Note that the style workaround (red) isn't what is failing, but this set/reset cycle ends up breaking the <<a>> (green) stereotype. Oddly, in my large diagrams, other stereotypes/css styles do not seem to be affected--only the ones used for arrows. I found this out when I tried replicating the arrow stereotype with a different name, but it also fails.

Without breaking up the diagram (explained above), how can I work around this? (Will I need to modify all arrows to use this set/reset cycle?)

1 Answer

0 votes
answered Mar 7 by dickmaley (4,120 points)

Style settings do work for all arrow types

image

@startuml
<style>

.r{
  LineThickness 3
  Linecolor red
}
.o{
  LineThickness 3
  Linecolor orange
}

.y{
  LineThickness 3
  Linecolor yellow
}

.g{
  LineThickness 3
  Linecolor green
}

.b{
  LineThickness 3
  Linecolor blue
}

.i{
  LineThickness 3
  Linecolor indigo
}

.v{
  LineThickness 3
  Linecolor violet
}
</style>
participant Bob
Bob -> Alice <<r>> : red
Bob ->> Alice <<o>> : orange
Bob -\ Alice  <<y>> : yellow
Bob \\- Alice  <<g>> : green
Bob //-- Alice  <<b>> : blue
Bob ->o Alice  <<i>> : indigo
Bob o\\-- Alice  <<v>> : violet
Bob <-> Alice <<r>> : red
Bob <->o Alice <<o>> : orange
@enduml

...