This documentation relates to an earlier version of Confluence.
View this page in the current documentation or visit the current documentation home.
Skip to end of metadata
Go to start of metadata

Code Formatting plugin modules are available in Confluence 2.2 and later versions

Code formatting plugin modules allow you to add new languages to the {code} macro. Whenever the code macro is invoked, the macro checks the 'language' parameter against the languages supported by the available formatting plugins, and uses that plugin to format the source code.

Code Formatting Plugins

Here is an example atlassian-plugin.xml file containing a single code formatter:

  • the class attribute defines the class that will be added to the available formatters. This class must implement com.atlassian.renderer.v2.macro.code.SourceCodeFormatter

The SourceCodeFormatter Interface

All code formatters must implement the following simple interface:

Formatter Priority

There is no concept of priority for formatters. If two formatters are installed and both return the same value from getSupportedLanguages(), one will be selected pretty much at random. If you want to avoid this behaviour, deactivate formatters that you no longer want to use.