Stash Syntax Highlighting

I followed this in an attempt to enable perl syntax highlighting based on a few additional file extensions...

So I've added this to the bottom of the file and restarted stash...


But files ending in au_irules and tmpl are not showing any syntax highlighting. Note these files are actually tcl syntax, but I figured it was closest to perl.

2 answers

1 accepted

1 vote
Answer accepted
Jason Hinch Atlassian Team Aug 14, 2013

As mentioned on the knowledge base article this is only available in Stash 2.7 and above. Stash 2.7 has not been released yet but will be within the coming days.


Thanks, looks like I'm all set for when it's released then.

I'm trying to get this working for Java syntax highlighting but to no avail. Can you please provide an example file?

Mine looks like this, but as you can probably see I'm just guessing at settings:

$ cat ../stash-home/ 


Logs don't show any relevant information. I'm using Stash 2.8.2 on Linux.

@Chris - there's a link to on the Configuring syntax highlighting for file extensions page. There you can see java and js should be already included. How are you verifying that this doesn't work? Some pages don't support syntax highlighting.

You've added my perl extensions, which unless you have perl files ending with au_irules and tmpl extensions isn't going to help you much.

To be honest, I don't fully understand what the syntax.highlighter.<language>.executables option does. Since I wanted to add more files to the perl syntax highlighting, I just copied the perl example and added my file extensions to the extensions option.

It looks like the highlights are only available when opening files trough the file browser. Not when viewing parts of commits, would be nice though.

Jason Hinch Atlassian Team Nov 07, 2013

Stash comes preconfigured and will hightax highlight a large number of files extensions and files which contain an known executable in their hashbang. Generally speaking you should rarely have to modify the default configuration.

Stash only syntax highlights source, not diffs. That means you will not be able to see syntax highlighting in the diff, commits or pull request views as they all render diffs. There is an open feature request for syntax highlighting diffs (STASH-2823).

Question - Stash may come preconfigured, but how do we see the configuration? A developer brought up that our clojure files ending in .clj aren't being highlighted; looking at the release notes @, clojure was added ~18 months ago. Presumably the highlight.js included in Stash would support it; I don't want to blindly add a link to the file, I'd like to see what extensions you are using for clojure first (since clojure doesn't really support hashbang detection) and then determine if .clj is wrong (on our part) and we should switch to what you're using, or if I should open up a support request to support the standard extension for clojure, or a million different things.

I spent a bunch of time (too much time) picking through the Stash 2.10.1 folder structure looking for clues, this is the closest I came:

var getLanguage = (function () {

        var pattern = /#!(?:\/(?:usr\/)?(?:local\/)?bin\/([^\s]+))(?:\s+([^\s]+))?/;
        var knownLanguages ='com.atlassian.stash.stash-web-plugin:source-view.syntax-highlighters') || {};
        var knownExtensions = {
            txt: 'text',
            log: 'text'

but I can't seem to find any configs or anything I can crack open and pick through in an editor.

What can you tell me?

Hi Kelly,

The version of highlight.js that we ship at the moment is 7.3. We ship the entire packed highlight file which you should be able to find here:


Our default configuration is a little harder to locate, it's stored in the stash-platform.jar:


It looks like Clojure is missing from our default list. I'll add it now to our next release (2.11), but feel free to add it to your own file for now and it should start working straight away.




Thanks! I made the change already, and I'll schedule a restart of Stash during planned maintenance later this week.


Any ETA as to when Stash will upgrade to version 8.0 of highlight.js? If not, could the upgrade be done on a local Stash server manually?


Adam Ahmed Atlassian Team Jan 14, 2014

We're experimenting with libraries other than highlight.js and there's a good chance we'll be moving away from that in the future. So there's no upgrade planned on our end.

You could theoretically do it on your local server by overwriting the highlight.pack.js file (and idea.css) but it's possible things will break. We wouldn't be able to help you with it in Support.


Erlang record access broke highlighting in highlight.js pre-8.0, but has been fixed since:

So if Stash could do syntax highlighting for Erlang in the next release it would make our life easier.

Also relevant:

Charles, I added the highlighter line for clojure (copy and pasted what you wrote), restarted Stash and .clj files still aren't highlighted. Any ideas? I know you/the docs said we could specify any executable present in the version of Highlighter you ship, which you said was 7.3 and clojure was first added to highlighter.js in 7.1 according to their changelog, but clojure isn't listed here:

(which may just be an oversight). Are you sure we can specify executables outside that list?


Assuming you're running Stash 2.7.0+ that should Just Work. I just double-checked it here and it wasn't working, I add the line to $STASH_HOME/, restarted and it starts highlighting.

We are talking about the source view here? If you view the source of the source view page you should see a WRM._unparsedData["com.atlassian.stash.stash-web-plugin:source-view.syntax-highlighters"] line up the top, can you see clojure in the set of values?

Yeah don't worry too much about that page - and in fact I should update it with Clojure now.



We're on 2.10.1, and it indeed shows up in view source:


But no highlighting :(

Maybe a bug with highlighter.js?

Ahha, it's a bug with highlighter.js. Any clj file that has a comment at the top it can't deal with. 99% of our clojure scripts have at least one comment at the top. I finally found one that didn't and highlighting worked.

;; example text &lt;-- this breaks highlighting.

Thanks Charles! I'd ask that you either update highlighter.js (and we push them to fix this if it's not already fixed in 8.0) or you switch to something else like you mentioned ;)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 14, 2019 in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder :  #!/bin/bash source "$(dirname "$0")/" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

283 views 0 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you