- Override syntax highlighting for a file type
- Disable syntax highlighting for a file type
- Configure maximum file size for highlighting
GitLab provides syntax highlighting on all files through the Rouge Ruby gem. It attempts to guess what language to use based on the file extension, which most of the time is sufficient.
The paths here are Git’s built-in
To override syntax highlighting for a file type:
- If a
.gitattributesfile does not exist in the root directory of your project, create a blank file with this name.
For each file type you want to modify, add a line to the
.gitattributesfile declaring the file extension and your desired highlighting language:
# This extension would normally receive Perl syntax highlighting # but if we also use Prolog, we may want to override highlighting for # files with this extension: *.pl gitlab-language=prolog
- Commit, push, and merge your changes into your default branch.
After the changes merge into your default branch,
*.pl files in your project are highlighted in your preferred language.
You can also extend the highlighting with common gateway interface (CGI) options, such as:
# JSON file with .erb in it /my-cool-file gitlab-language=erb?parent=json # An entire file of highlighting errors! /other-file gitlab-language=text?token=Error
To disable highlighting entirely for a file type, follow the instructions for overriding
the highlighting for a file type, and use
# Disable syntax highlighting for this file type *.module gitlab-language=text
By default, GitLab renders any file larger than 512 KB in plain text. To change this value:
gitlab.ymlconfiguration file for your project.
Add this section, replacing
maximum_text_highlight_size_kilobyteswith the value you want.
gitlab: extra: ## Maximum file size for syntax highlighting ## https://docs.gitlab.com/ee/user/project/highlighting.html maximum_text_highlight_size_kilobytes: 512
Commit, push, and merge your changes into your default branch.