doc/user/project/repository/files/highlighting.md
{{< details >}}
{{< /details >}}
GitLab provides syntax highlighting for files through two complementary systems:
The paths here use the .gitattributes interface in Git.
[!note] The Web IDE and snippets use the Monaco Editor for text editing, which internally uses the Monarch library for syntax highlighting.
[!note] The Web IDE does not support
.gitattributesfiles. For more information, see epic 18651.
To override syntax highlighting for a file type:
If a .gitattributes file 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 .gitattributes file
declaring the file extension and your desired highlighting language:
# This extension typically receives Perl syntax highlighting. If you
# also use Prolog, you can override highlighting for this file extension:
*.pl gitlab-language=prolog
Commit, push, and merge your changes into your default branch.
After the changes merge into your default branch,
all *.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 gitlab-language=text:
# Disable syntax highlighting for this file type
*.module gitlab-language=text
The following file size limits apply to the syntax highlighters:
To change the Rouge highlighting limit:
Open the gitlab.yml
configuration file for your project.
Add this section, replacing maximum_text_highlight_size_kilobytes with the value you want.
gitlab:
extra:
## Maximum file size for syntax highlighting
## https://docs.gitlab.com/user/project/repository/files/highlighting/#configure-maximum-file-size-for-highlighting
maximum_text_highlight_size_kilobytes: 512
Commit, push, and merge your changes into your default branch.