How can I escape double square brackets?

0 votes
asked Jul 30, 2013 by AndrewGHo (310 points)

In PlantUML sequence diagram input files, I discovered that text inside double square brackets (like "[[text]]") disappears. Searching the PlantUML documentation for "[[" or "bracket" did not explain why. Searching this Q&A site, I found http://plantuml.sourceforge.net/qa/?qa=390/putting-something-under-actor-name which means that you can make HTML links using double square brackets (like "[[http://www.google.com Google]]").

So, for example, this input:

A -> B: Action [Single] [[Double]] [[[Triple]]]

Results in the text "Action [Single] [Triple]" being rendered.

I need one of my labels to include a string that has double square brackets surrounding it (it represents a list of lists, with syntax like "[[a, b], [c, d]]"), and I can't seem to find any way I can write this. I've tried various combinations of using backslashes to escape one or the other square bracket, as well as using the HTML entity &91;, or trying to increase the number of brackets, and I can't make it work. I did find that a newline, followed by quadruple brackets, and a space between the last open bracket and the text, does work. So this input:

A -> B: [[[[ Does Not Work]]]]

A -> B: Also [[[[ Does Not Work]]]]

A -> B: But This One\n[[[[ Does Work]]]]

Renders as this graphic:

Is there any way to just make the first or second variants work?

2 Answers

0 votes
answered Jul 31, 2013 by plantuml (134,510 points)
Hello,

Thanks for the report : we will fix that quickly.
commented Jul 31, 2013 by AndrewGHo (310 points)
Thanks for the quick response!

Just to be clear, the actual thing I'm fishing for is to have some canonical way to render double-bracketed text, for example, backslash escaping one or more of the brackets, putting them in quotes, or whatever. The newline vs. no-newline behavior is vexing, but kind of a red herring—the "[[[[ foo]]]]" syntax is a bit more cumbersome than something like "\[[foo]]" or even just automatically not trying to make a link, especially if the first thing after "[[" doesn't look like a URL.
0 votes
answered Jul 31, 2013 by plantuml (134,510 points)

This bug was actually a mix of several bugs.

So we have published V7975 which allows to escape bracket:

A -> B: Action1 \[\[foo foo\]\]

Note that (in this version) you can escape only the second bracket (if you want):

A -> B: Action1 [\[foo foo]]

Unfortunatly, only escaping the first does not work (yet).

Guessing if the brackets contain or not an URL is too complicated or risky, so we won't implement that.

Hope this helps!

commented Jul 31, 2013 by AndrewGHo (310 points)
I an confirm that V7975 fixes the problem for me, thanks for the quick work!

I'm now using the [\[foo]] syntax which is totally fine as a workaround. I agree \[[foo]] would be marginally better, so I'll keep watch on future releases for that!  :)
...