Configuring syntax highlighting for file extensions

Bitbucket Server versions up to 3.4 used HighlightJS to provide syntax highlighting. Bitbucket Server 3.5 changed to use CodeMirror for this, and HighlightJS has been removed. You are encouraged to update your custom mappings format before support is removed in Bitbucket Server 4.0. Configuration for Bitbucket Server 3.4 and below can be found here.

Bitbucket Server versions use the versions of CodeMirror in the version matrix below, and support all the language mappings, extensions and aliases available with that CodeMirror distribution – see Note that language modes introduced in later versions of CodeMirror won't be available until Bitbucket Server uses an upgraded version of CodeMirror.

A language is selected based on the default mappings defined in CodeMirror. The file extensions and hashbangs configured for each language in CodeMirror can be overridden in Bitbucket Server 3.5 (and later), and additional mappings specified, using the file – see Bitbucket Server config properties.

Properties are shaped as follows:
syntax.highlighter.<MIME type>.executables=exe1,exe2
syntax.highlighter.<MIME type>.extensions=ext1,ext2

Where the <MIME type> refers to the MIME type that the highlighter expects as described on the CodeMirror website.

Properties ending in executables should provide a list of strings to search for in a shebang header to determine the executable language. E.g., to syntax highlight NodeJS bin files (that start with "#!/usr/bin/node")as JavaScript, you can use:
syntax.highlighter.text/javascript.executables=node # NOTE: this particular configuration is already handled for you

Properties ending in extensions should provide a list of file extensions for which the contents should be highlighted as <MIME type>.

For example, you may have project files that are XML but don't end in .xml you can defined additional types like this:

After updating your file you need to restart Bitbucket Server for the configuration changes to take effect. See Bitbucket Server config properties.

In addition to the base configurations, defined by CodeMirror, Bitbucket Server provides the following extra configurations:

MIME Type Executables
text/x-sh sh, bash, zsh
text/x-erlang escript
text/javascript node


text/x-python python
text/x-ruby ruby



Bitbucket Server/CodeMirror version matrix

Stash/Bitbucket Server 3.5 3.6 3.7 3.8 3.9 3.10 3.11


4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10 4.11 4.12 4.13 4.14 5.0 5.1 5.2 5.3 5.4
CodeMirror 4.7 4.8 4.12 4.12 4.12 4.12 5.3 5.3 5.3 5.8 5.8 5.8 5.8 5.12 5.12 5.16 5.16 5.16 5.16 5.19 5.19 5.19 5.19 5.19 5.19 5.19 5.29
Last modified on Sep 19, 2017

Was this helpful?

Provide feedback about this article

Not finding the help you need?

Ask the community

Powered by Confluence and Scroll Viewport.