Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Background Shade the Codeblock?

Is there no way to make the background for the macro code block a different color?  Or any other way to make it stand out? 

It just looks odd with only the box around it.  I've seen this asked in alot of other places but I haven't seen  a solution yet. 



1 answer

1 vote
Daniel Eads Atlassian Team Mar 10, 2021

Hi @Matthew Oney ,

The code block macro in Confluence Server / Data Center comes with several themes. By selecting the macro, you can click the Edit button to modify the macro's options:


Aside from selecting a language for syntax highlighting and enabling line numbers, you can choose one of several themes. All the themes except 'Eclipse' and 'Confluence' come with dark backgrounds. Here's a screenshot of the snippet above using the Midnight theme:


You can even set a particular language as default for syntax highlighting, and change the default theme. (It's the 'Confluence' theme if this hasn't been configured yet).

  1. Go to  > General Configuration > Configure Code Macro.
  2. Select a Default Theme and Default Language.
  3. Choose Save.

If you're adding the macro using wiki markup, you can also pass options like the theme in as parameters. Details are available in the code macro's documentation. 


On the Confluence Cloud side of things, the code macro has been replaced by the code snippet in the new editing experience. Currently code snippets aren't customizable (again, this is only Cloud) but a feature request for customizing them is fairly active . In Cloud however, the code snippets have a prominent grey background and stand out from the page fairly well.

Daniel | Atlassian Support

Got it, that's awesome and will definitely work! 

Last question - In docuwiki there is a add-on for copy/paste; you left click in the code block and it copies the contents to your clipboard, is there something similar in confluence? 

Thank you for your help!

Daniel Eads Atlassian Team Mar 11, 2021

Just noting another difference between Confluence Cloud and Confluence Server here for the benefit of other folks coming across this answer. On the Cloud code snippet, there's a copy button in the upper right:



However on Server, there's not a built-in button like this. I've checked the marketplace and found two code block apps that do provide this:

But it is pretty quick to "select all" with the out-of the-box code macro. Just double-click somewhere in the code block (after the first line) and all the text in the code block will be selected. From there you can cmd/ctrl+C or right-click to copy. Not as fast as a single button, but still faster than dragging to select all the text.

Actually this is crazy... so I can only have the 'default' code macro? 

I can't have one for python that I call with like ...

one for powershell code block


There's no way to have more than one codeblock? 

Thanks for you patience and help with this!

Oh, interesting use-case! Most people call {code} and then use the Edit button on the macro to change the options (including the language). Using the Default Language setting at the top of this thread, you can change which language the block will pre-set when you just call {code}.

But you're right - it's all {code} and there aren't specific macros for each language. Using wiki markup (outside the editor), you can pass in the language you want when creating the macro... but it's still not as simple as just a macro called {powershell} like you mentioned.

Checking around marketplace again, there's no apps that add multiple macros for all the various languages you might want to use. They all start with one macro, and you need to edit the options to choose a non-defaulted language.

One possibility might be to create your own user macro that calls the code block macro with whatever parameters you want - and create similar user macros for each of the languages you want to shortcut. I haven't personally seen an implementation of this, but I did find a (rather old) thread here on Community where folks discussed something similar: Preformatting code blocks and tables using user macros 

Ok, I may be able to play around and use that... thank you for your help!!

Like Daniel Eads likes this

Haha hopefully this is the last question(maybe)...

So this appears to work...

## This is an example macro
## @Param Title:title=Title|type=string|desc=Title
<ac:macro ac:name="code">
<ac:parameter ac:name="title">Python</ac:parameter>
<ac:parameter ac:name="language">python</ac:parameter>
<ac:parameter ac:name="theme">eclipse</ac:parameter>
<ac:parameter ac:name="linenumbers">true</ac:parameter>
<ac:parameter ac:name="firstline">1</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">BLOCK</ac:parameter><ac:plain-text-body><![CDATA[$body]]></ac:plain-text-body>



buuuuut when I save it I get - 


Actually it seems to OK if you switch it from 'Escape' to 'Unrendered' , still testing...

Yeah, it seems OK... this will definitely work.  @Daniel Eads  thank you so much for the help!!

Like Daniel Eads likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

Confluence Mythbusters: Does Atlassian even use Confluence?

Hi, Confluence collaborators! As part of #Confluence-Collaboratory month, we’ve created a very special Mythsbusters segment, where we're dive into an interesting myth and uncover the truth behind i...

1,381 views 7 29
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you