Static syntax highlighting is highlighting of code that the user can't change. This includes code snippets, iterations, and more.
The online editor does not use static syntax highlighting as the user can change the code on the fly. If you'd like to know more of how we handle syntax highlighting in the online editor, check the dynamic syntax highlighting docs.
Static syntax highlighting is done using the highlightjs library.
When adding support for your language, there are three options:
To enable highlightjs support for your track's language, you'll need to modify the track's config.json file.
Within the config.json
file, add/set the online_editor.highlightjs_language
key to the appropriate highlightjs language identifier (which can be found in the documentation).
{
"online_editor": {
"highlightjs_language": "csharp"
}
}
To use an existing plugin, it needs to be published on NPM. If the plugin isn't published on NPM, you can either:
The next step is to Enable the plugin.
To enable a plugin (which must be published on NPM), start a topic on the forum requesting us to add support for the plugin to the website. We (Exercism) will then create a Pull Request that adds the plugin to the website. Once the PR is merged, you can enable highlightjs support by following the instructions in the Configuring track section.
If you'd like to create plugin, you have two options for hosting:
Once you have a repo, follow the language contribution instructions to implement the plugin.
You'll then need to publish the plugin on NPM. The next step is to Enable the plugin.
Your language's syntax (closely) resembles another language's syntax, in which case you could consider using the syntax highlighting of that language for your language. To do so, configure the track to use the other language's highlightjs language identifier. See the Configuring track section for more information.