Configuring syntax highlighting for file extensions

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

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.

*Fisheye および Crucible は除く

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 http://codemirror.net/mode/. 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 bitbucket.properties file – see Configuration properties.

Properties are shaped as follows:

bitbucket.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:

bitbucket.properties
syntax.highlighter.text/javascript.executables=node # NOTE: this particular configuration is already handled for you

Bitbucket makes use of a regular expression to determine the executable language, based on the strings provided in the first line of the file. To make it a valid shebang, it has to start with any of the following patterns:

  • #!/usr/local/bin/...
  • #!/usr/bin/...
  • #!/local/bin/...
  • #!/bin/...

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:

bitbucket.properties
syntax.highlighter.application/xml.extensions=vcproj,vcxproj

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

In addition to the base configurations, defined by CodeMirror, Bitbucket Server 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

text/x-fortran

F90

CodeMirror/Bitbucket Server version matrix

CodeMirrorStash/Bitbucket Server
4.73.5
4.83.6
4.123.7、3.8、3.9、3.10
5.33.11、4.0、4.1
5.84.2、4.3、4.4、4.5
5.124.6、4.7
5.164.8、4.9、4.10、4.11
5.194.12, 4.13, 4.14, 5, 5.1, 5.2, 5.3
5.295.4, 5.5, 5.6, 5.7, 5.8, 5.9
5.365.10、5.11
5.385.12, 5.13, 5.14, 5.15, 5.16, 6, 6.1, 6.2, 6.3, 6.4
5.486.5, 6.6, 6.7, 6.8, 6.9, 6.10, 7.0, 7.1
5.52.27.2, 7.3, 7.4, 7.5, 7.6, 7.7
5.58.27.8、7.9
5.59.17.10
5.59.27.11
5.60.07.12, 7.13, 7.14, 7.15, 7.16, 7.17, 7.18, 7.19, 7.20, 7.21, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 8.10, 8.11, 8.12, 8.13, 8.14, 8.15, 8.16, 8.17, 8.18, 8.19



説明 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.
Last modified on Mar 4, 2024

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.