Configuring syntax highlighting for file extensions

Miscellaneous

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

Stash versions up to 3.4 used HighlightJS to provide syntax highlighting. Stash 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 Stash 4.0. Configuration for Stash 3.4 and below can be found here.

Stash 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 http://codemirror.net/mode/. Note that language modes introduced in later versions of CodeMirror won't be available until Stash 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 Stash 3.5 (and later), and additional mappings specified, using the stash-config.properties file – see Stash config properties.

Properties are shaped as follows:

stash-config.properties
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:

stash-config.properties
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:

stash-config.properties
syntax.highlighter.application/xml.extensions=vcproj,vcxproj

After updating your stash-config.properties file you need to restart Stash for the configuration changes to take effect. See Stash config properties.

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

MIME TypeExecutables
text/x-shsh, bash, zsh
text/x-erlangescript
text/javascriptnode

text/x-perl

perl
text/x-pythonpython
text/x-rubyruby

Stash/CodeMirror version matrix

Stash3.53.63.73.83.93.103.11
CodeMirror4.74.84.124.124.124.125.3
Last modified on Nov 15, 2018

Was this helpful?

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