Confluence: How to escape double quotes in user macros?


I'm writing a lot of user macros and stumble upon this one problem every now and then:

I have no idea how to escape double quotes properly. In this specific case I'm writing a macro that holds Bob Swifts run&cli plugins, where quotes are needed. Here's a code example:

#set($globalHelper = $action.getHelper())

#set ($update = $globalHelper.renderConfluenceMacro("{run:replace=status:green:Lorem ipsum?:radio::green::yellow::red|titleRun=lorem!}
--action storePage --space xxx --title "yyy" --content "zzz"
Status aktualisiert.

The part within the {cli-stuff makes the problems.

I tried single quotes, escaping with backslash...even HTML entities, nothing is working properly. With quotes like above I get an error message when using the macro (of course), when escaping the values are set exactly with the chars I used to escape.

I'm really hoping there's a solution for this :)

2 answers

1 accepted

Hello Superuschi,

I stumbled into the same problem today and found that:

Thus, I solved my problem by introducing a constant containing the quote character

#set( $q = '"' )

and using it like that:

#set( $style = "style=${q}$paramStyle${q}" )

Hope that helps.


Your solution also worked for me. I needed to expand a file name using a user supplied variable but the period and suffix were causing problems. Ther period needed to be separated from the variable name by whitespace or the variable would not be replaced witht the user supplied value :-(

I used this technique to create a suffix variable that was set to ".rss" and then my macro worked like a charm.


Nice to hear that, Matthew.

Okay, I figured that in this case, I can just use no quotes at all in the cli-part. Won't work in other cases though.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

396 views 5 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you