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

How do I add a custom theme to the code block macro?

Jim.Creasman December 19, 2019

I'm trying to extend the Code Block macro in Confluence to support a few new languages typically used on the mainframe (e.g., s/390 Assembler).  I have successfully added the new language following the instructions in Confluence and SyntaxHighlighter.  However, none of the existing color schemes are compatible with how I want the highlighting to look.  I see that SyntaxHighlighter also provides for developing custom color schemes.  How do I extend the available color scheme choices for Code Block sections in Confluence?

2 answers

1 vote
Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 2, 2020

Hello Jim,

Welcome to Atlassian Community. It's nice to meet you!

It's not possible to customize the theme of the code block macro, but I've raised a feature request below for this:

In the meantime, you'll be able to use Marketplace add-ons to customize the theme of your code blocks:

Let me know if you have any questions about that.

Regards,

Shannon

0 votes
Jim.Creasman January 2, 2020

Thanks for the reply.  Unfortunately, none of the plugins in the marketplace do what I need.  They don't support the languages I need.  

Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 3, 2020

Hi Jim,

Thank you for letting me know. One of the add-ons for Cloud supports Assembly languages but not the ones for Server.

The custom brush syntax that you use has to adhere to Custom Brush Syntax, but it looks like you can include colors that way. Have you already tried calling the colors you need with CSS and that doesn't work?

Regards,

Shannon

Jim.Creasman January 3, 2020

Yes, after adding the custom brushes I've been playing around with the colors and available themes.  My goal is to make the code look like it does in the native z/OS terminal window since the code snippets we are documenting will be viewed by this set of developers.  None of the color choices get it right 100%.  

The SyntaxHighlighter on which the Code Block macro is based supports adding custom themes as well as custom brushes.  My suggestion (and what I believe you are saying in the ticket you opened) is to also expose this interface to anyone wishing to customize the macro.  I've added myself to the watch list for any future updates.  In the mean time I'm exploring writing my own macro for this purpose.

Thanks,

Jim

Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 6, 2020

Hi Jim,

Yes, I'm sorry, I did mean via the UI, so I've updated the feature request to state this.

Good luck on working using the brush syntax. If you end up with anything you'd like to share, please feel free to share it here!

Regards,

Shannon

Shane Presley July 27, 2022

I have a similar requirement to replicate the highlighting color scheme from a UI that my users are accustomed to and have hit this same wall. 

It seems that in the years since this thread the links to the Custom Brush Syntax has gone dead and the brush files described in https://confluence.atlassian.com/doc/code-block-macro-139390.html

You can see examples in <install-directory>/confluence/includes/js/third-party.

are from a much older version of the library (1.5) than what is shipped with Confluence (3.0).  I managed to extract the actual brushes used by Confluence from the browser inspector which was extremely tedious. 

The SyntaxHighlighter library has moved on to v4 and is now at https://github.com/syntaxhighlighter/, documentation is still pretty sparse though. The library itself does support custom themes but not Atlassian.

It's just a CSS file

/* module-key = 'com.atlassian.confluence.ext.newcode-macro-plugin:sh-theme-confluence', location = 'sh/styles/shThemeConfluence.css' */

and I would be more than happy to just be able to upload my own css with the brush.  Icing on the cake would be the ability to specify a default theme per brush. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events