How can I include an ampersand (&) in a code block macro?

I would like to include literal ampersands (&) in code blocks using the code block macro. Is this possible?

1 answer

0 vote
Stephen Deutsch Community Champion Jul 26, 2017

Could you be more specific? As far as I know, the Confluence Code Block macro supports ampersands in the code. Is there something specific you're trying to do or some specific problem you're running into?

I discovered that the ampersand (&) is replaced with the corresponding HTML entity (&) whenever it is followed by a dollar sign ($).

Ampersand in code block macro.png

Other ampersands are rendered correctly.

I found that the problem does not happen when the default syntax highlighting is enabled, but only when we use a custom one. I gather the problem lies therein. I’ll see if I can fix it.

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 Apr 13, 2018 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...

2,944 views 27 12
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