# Configure which programming languages are available for syntax highlighting

**URL:** https://meta.discourse.org/t/configure-which-programming-languages-are-available-for-syntax-highlighting/239717
**Category:** Site Management
**Tags:** how-to, customization
**Created:** [September 22, 2022, 1:43am UTC](https://meta.discourse.org/t/configure-which-programming-languages-are-available-for-syntax-highlighting/239717 "2022-09-22T01:43:43Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [September 22, 2022, 1:43am UTC](https://meta.discourse.org/t/configure-which-programming-languages-are-available-for-syntax-highlighting/239717/1 "2022-09-22T01:43:43Z")

</div>

> 🔖 This guide explains how to configure which programming languages are available for syntax highlighting in Discourse.
> 
> 🙋 Required user level: Administrator

Syntax highlighting enhances readability in code blocks by applying formatting based on the programming language. You can customize the languages available for syntax highlighting in Discourse.

## Configuring the highlighted\_languages site setting

To configure the list of programming languages for syntax highlighting:

1. Navigate to the Admin panel.
2. Go to `Config` → `Content` → `Posts and Topics`.
3. Find the `highlighted_languages` site setting.

 ![Screenshot of highlighted_languages site setting](https://global.discourse-cdn.com/meta/original/4X/7/c/5/7c5672eadc48bf0e292446272d74073c37a6d23a.png)

In this setting, you can define which languages will be available for syntax highlighting. Enter the names of the languages you want to support, separated by commas.

## Related settings

There are two additional site settings related to syntax highlighting, found in the same area:

- **`default_code_lang`** — The default language applied to code blocks when no language is specified. Defaults to `auto`, which attempts to detect the language automatically.
- **`autohighlight_all_code`** — When enabled, applies syntax highlighting to all `<code>` blocks, even those without a language class specified. Defaults to off.

## Adding support for additional languages

If your desired language is not bundled with highlight.js, you can add it via a theme component using the `api.registerHighlightJSLanguage()` plugin API. Below are the steps to achieve this:

1. **Locate a module for your language:** Find a highlight.js language definition that supports the language you want to add. For example:

- Solidity: `https://github.com/highlightjs/highlightjs-solidity`
- Supercollider: `https://github.com/highlightjs/highlightjs-supercollider`

1. **Integrate the module using a theme component:**

- Obtain the HighlightJS language definition for the desired language.
- Create a new [theme component](https://meta.discourse.org/t/installing-a-theme-or-theme-component/63682) in Discourse.
- In the theme component’s JavaScript, use the plugin API to register the language:

```javascript
api.registerHighlightJSLanguage("languageName", languageDefinitionFunction);

```

- See [Install a new language for Highlight.JS via a theme component](https://meta.discourse.org/t/install-a-new-language-for-highlight-js-via-a-theme-component/97language) for a complete example.

> Last edited by @SaraDev 2024-07-16T22:41:30Z
> 
> > **Check document**
> >
> > Perform check on document:

---

<div class="post-metadata">

### Author: ![elopio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elopio/32/218413_2.png) [@elopio](https://meta.discourse.org/u/elopio)
#### Post date: [November 9, 2022, 12:17am UTC](https://meta.discourse.org/t/configure-which-programming-languages-are-available-for-syntax-highlighting/239717/2 "2022-11-09T00:17:42Z")

</div>

I want to add solidity, a language that is not bundled with highlight.js. It is provided in this package: [GitHub - highlightjs/highlightjs-solidity · GitHub](https://github.com/highlightjs/highlightjs-solidity)

I’m not sure how to do this. I’ve added it to the discourse settings. Is it going to find the package for me and take care of everything, or do I have to put this extra javascript package somewhere? I’ll appreciate some guidance 🙂

---

<div class="post-metadata">

### Author: ![yaxu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yaxu/32/178942_2.png) [@yaxu](https://meta.discourse.org/u/yaxu)
#### Post date: [November 29, 2022, 12:49pm UTC](https://meta.discourse.org/t/configure-which-programming-languages-are-available-for-syntax-highlighting/239717/3 "2022-11-29T12:49:52Z")

</div>

I’m also interested in this, to support syntax highlighting of the supercollider language via [GitHub - highlightjs/highlightjs-supercollider · GitHub](https://github.com/highlightjs/highlightjs-supercollider)

---

<div class="post-metadata">

### Author: ![pacharanero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pacharanero/32/500583_2.png) [@pacharanero](https://meta.discourse.org/u/pacharanero)
#### Post date: [January 19, 2023, 12:57pm UTC](https://meta.discourse.org/t/configure-which-programming-languages-are-available-for-syntax-highlighting/239717/4 "2023-01-19T12:57:42Z")

</div>

Bump. If we want to add syntax highlighting support for languages not already in highlight.js, is there any way to add this directly eg via a theme component, or do we need to get the upstream highlight.js people to accept a PR with the additional syntax?

I’m asking as there is an fairly esoteric pair of languages Archetype Description Language (ADL) and Archetype Query Language (AQL) which the owners of [discourse.openehr.org](http://discourse.openehr.org) would like to be syntax highlight-able. They have technical capability to build a parser/highlighter, they just need to know how to make it work in a Discourse.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [January 19, 2023, 1:18pm UTC](https://meta.discourse.org/t/configure-which-programming-languages-are-available-for-syntax-highlighting/239717/6 "2023-01-19T13:18:13Z")

</div>

It’s totally doable as a theme component! Once you get the HighlightJS script ready ping me here and I can help you build the #Customization > Theme component .

---

<div class="post-metadata">

### Author: ![pacharanero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pacharanero/32/500583_2.png) [@pacharanero](https://meta.discourse.org/u/pacharanero)
#### Post date: [January 19, 2023, 1:38pm UTC](https://meta.discourse.org/t/configure-which-programming-languages-are-available-for-syntax-highlighting/239717/7 "2023-01-19T13:38:20Z")

</div>

Thanks @Falco ! I will get the script built and will post back when ready.

---

<div class="post-metadata">

### Author: ![putty](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/putty/32/370902_2.png) [@putty](https://meta.discourse.org/u/putty)
#### Post date: [August 26, 2024, 8:30pm UTC](https://meta.discourse.org/t/configure-which-programming-languages-are-available-for-syntax-highlighting/239717/8 "2024-08-26T20:30:18Z")

</div>

In the last week or two, I’ve noticed that the code highlighting doesn’t seem to be registering when it should. [See here for an example](https://developer.sailpoint.com/discuss/t/leaver-process-deprovisioning/78196/2?u=derek_putnam). When I specify a language (java in the case above), it will apply the colors.

Here is another example for XML:  
[https://developer.sailpoint.com/discuss/t/get-application-roles-as-well-as-search-for-the-roles/78194?u=derek\_putnam](https://developer.sailpoint.com/discuss/t/get-application-roles-as-well-as-search-for-the-roles/78194?u=derek_putnam)

We have dozens of languages to be detected. I see the subtext under this setting says that too many can cause it to perform poorly, but I don’t think we added anything recently.

 ![CleanShot 2024-08-26 at 16.27.17](https://global.discourse-cdn.com/meta/original/4X/3/2/c/32c6773ce2d813e3f36aab35387efeb63de232fb.png)
