Installing additional Languages for Code Block Macro

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Purpose

As described in Code Block Macro, you can add new language highlighting to Code Block macro. This document explains how to identify the custom added languages in your Confluence instance and provides a list of open suggestions and references to other Code languages which are not part of the default ones. 

Solution

Adding a new Code Language

To add an additional language:

  1. Go to Administration  > General Configuration > Configure Code Macro.
  2. Choose Add a new language.
  3. Locate your language file and enter a Name for the new language (this will appear when selecting the language).
  4. Choose Add.

Language files must be correctly formatted JavaScript files and adhere to the Custom Brush syntax. You can see examples in <install-directory>/confluence/includes/js/third-party.

Identifying added Code Languages

The Code Block Macro uses syntax highlighter brushes in the background, and these can be installed manually. When a new language in the code macro is added, Confluence wraps the brush file into a JAR File named install-language-LANGUAGENAME-XXXX.jar  which is located under the CONFLUENCE_HOME/temp directory. In order to invoke it, a new entry is added into the PLUGINDATA table of the Confluence schema.

If you want to check what custom languages are installed, the simplest way is to run the following SQL statement: 

SELECT substr(PLUGINKEY,42,strpos(substr(PLUGINKEY,42),'.')-1) AS LANGUAGE, FILENAME
FROM PLUGINDATA
WHERE PLUGINKEY LIKE 'com.atlassian.confluence.ext.code.custom.%'

Besides, the full list of out-of-the-box languages available in the Code block macro are available in our official documentation: Code Block Macro

Suggestions for Implementing new Code Languages

There are multiple suggestions opened for the implementation of additional languages as part of the out-of-the-box languages. If you or your business has any interest in having any of these suggestions implemented, feel free to vote to assess collectively the interest on each of them. 


Additional Code Language files

Please be aware that this material is provided for your information only and that you use it at your own risk.

Atlassian Support cannot guarantee to provide any support for the code outlined on this page as customisations are not covered under Atlassian Support Offerings.

It is possible to find some brushes files available in our Confluence Knowledge Base and the Atlassian Community: 


Last modified on Oct 5, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.