Escape Character for Curly Braces

0 votes
asked Feb 24, 2023 in To be sorted by anonymous
Hi,

I will keep it short. ~ does work for [], but not for {}. What am I doing wrong? Is it not possible to escape curly braces? I need curly braces in tooltips. Example here:

https://www.plantuml.com/plantuml/uml/SoWkIImgAStDuNBCoKnELT2rKt3AJx9IS2mjoKZDAybCJYp9pCzJ24ejB4qjBk42oYde0jM05MDHLLoGdrUSoeLkM5u-K5sHGY9sGo6ARNHr2QY66kwGcfS2SZ00

EDIT: Looked for similar questions before and just found one afterwards. Sorry. Seems like there is no way? https://forum.plantuml.net/17208/curly-braces-tooltip-would-show-json-something-like-tooltips
commented Feb 25, 2023 by albert (3,540 points)
I neither see curly ({}) nor square ([]) brackets in your example, so please show an example where the problem occurs.
commented Feb 27, 2023 by anonymous
Sorry, my bad, it seems like I didnt refresh the link after writing my example. Here is the updated link that has curly braces in a tooltip to break it and shows that it is not working to escape it:
https://www.plantuml.com/plantuml/uml/SoWkIImgAStDuNBCoKnELT2rKt3AJx9IY8wkBixCBSX9LIZ9pyyfoInGACb8B54epo_ABgw5YSN6OkhAouUeoinBhusE9L9bTIsnPjPLro7KAgGM9oSMf2e07PfVN9oPb9CArEsGcfS2z0y0

2 Answers

0 votes
answered Feb 27, 2023 by anonymous

You can use double-quotes around the tooltip instead of curly brackets:

@startuml
Alice -> Bob: [["working{}" tooltip]]
Alice -> Bob: [["working[]" tooltip]]
@enduml

commented Mar 4, 2023 by anonymous
Thanks for your answer. This already helps, but unfortunately, it does not work for my specific use case. I might try to adjust the format somehow, but I have to add a random character as my display text sometimes starts with curly braces. Do you have any more ideas to fix it? currencly I dont really think its a nice solution, but better than having no curly braces at all.
https://www.plantuml.com/plantuml/uml/JSun2W8n48NXVa_nsDuBMCZgBMJPOfAC93Wwaan44UzkaifYgd_uU4inobPlCXqbUSRkW9EwFTPrjfWAIjGg0OvXiPsgM7hC-8n8tYg9l97AV_vkszIGRWrqQ6UjYFJiJw0GOFoonbuqCtpD3N6PF9SPaguy_EvC2zz3c_S3
0 votes
answered Mar 24, 2023 by Martin (9,120 points)

You can use <U+007B> for the left curly bracket.

@startuml
Alice -> Bob: [["this is the tooltip" <U+007B>this is the text starting with a curly bracket}]]
@enduml

Idea using a macro:

@startuml
!function linktext(txt)
!if (%substr(txt,0,1) == "{")
  !return "<U+007B>" + %substr(txt,1,%strlen(txt)-1)
!else
  !return txt
!endif
!endfunction

Alice -> Bob: [["this is the tooltip" linktext("{this is the text starting with a curly bracket}")]]
@enduml

...