How can I use a user macro in a {code} block?

I have a user macro called {username} which works great in an {info} block but gets displayed verbatim as '{username}' in a {code:language=bash} block. How can get the {code:language=bash} to respect the macro?

2 answers

{code} and {noformat} are special-case macros in Confluence - they both ignore any wiki markup therin. You could get around it in two ways:

1. Use a different type of block (eg. {quote}).

2. Inject the value you want to put in using {replace-and-render} or Reporting. Eg:

  {replace-body}{code:language=bash}Blah blah %username% blah blah{code}{report-body}

Hope that helps!


David Peterson

P.S. You'll need the 'Replace and Render' plugin for that example to work. :)

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Friday in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

287 views 11 10
Join discussion

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