Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Michael Lowry July 26, 2017

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

1 answer

1 vote
Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 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?

Michael Lowry July 26, 2017

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.

Like Ryan_Lei likes this
Michael Lowry July 27, 2017

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.

Matthias Pigulla
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 14, 2018

Just stumbled across this as well. 

Using a "code block" macro,

foo & bar

will be shown as-is, but 

http://host/foo&bar 

will turn into 

http://host/foo&bar

I suspect that's bug, probably some filter trying to escape URLs for <a> tags?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events