# Adding support for \`julia-repl\` syntax highlighting

**URL:** <https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357>\
**Category:** Meta Discussion\
**Created:** [September 28, 2023, 3:28pm UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357 "2023-09-28T15:28:17Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [September 28, 2023, 3:28pm UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/1 "2023-09-28T15:28:18Z")

</div>

Is it possible to add custom syntax highlighting to our Discourse instance? In the julia zulip chat (please come check it out! [https://julialang.zulipchat.com/](https://julialang.zulipchat.com/)), we have an additional highlighting option called `julia-repl` which is designed for displaying code copy-pasted from the REPL to help visually distinguish between inputs and outputs:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/f/ff91d4c45f34144a680eeeb2266b5b0e5ccc3d86.png)

Would it be feasible to have this in Discourse as well? cc @mbauman

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [September 28, 2023, 3:32pm UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/2 "2023-09-28T15:32:32Z")

</div>

We do have support turned on for `julia-repl`, just use that as the “type” of a code block like:

````julia
```julia-repl
```

````

I don’t know if its rules are meaningfully different, though… quick test:

julia:

```julia
julia> @benchmark foo(1, "bar", 'z', :foo)::Nothing
BenchmarkTools.Trial: 10000 samples with 999 evaluations.
# ...

```

julia-repl:

```julia-repl
julia> @benchmark foo(1, "bar", 'z', :foo)::Nothing
BenchmarkTools.Trial: 10000 samples with 999 evaluations.
# ...

```

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [September 28, 2023, 3:34pm UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/3 "2023-09-28T15:34:56Z")

</div>

Oh I thought from my experiments with `julia-repl` here that it just didn’t do any syntax highlighting like if I did

````julia
```agbasasdasdas

````

but I see now that there is actually some stuff going on, sorry for the noise then! I should have checked more carefully

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [September 28, 2023, 3:35pm UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/4 "2023-09-28T15:35:43Z")

</div>

Yeah, it looks like it’s working well. I think it’s the themeing that could probably be improved — for example, `julia>` is tagged as a “prompt\_” class but it’s not getting any special formatting.

---

<div class="post-metadata">

**Author:** ![ShalokShalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shalokshalom/32/52462_2.png) [@ShalokShalom](https://discourse.julialang.org/u/ShalokShalom)\
**Post date:** [October 3, 2023, 9:49am UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/5 "2023-10-03T09:49:24Z")

</div>

I just found the documentation using this tag, but to no effect:

> <https://github.com/JuliaLang/Pkg.jl/blob/master/docs/src/environments.md#creating-your-own-environments>

Neither Github, nor our documentation highlights anything.  
And [highlight.js](https://github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md) does seem to alias julia-repl to julia, instead of considering it as its own syntax.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 3, 2023, 8:48pm UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/6 "2023-10-03T20:48:27Z")

</div>

> [@ShalokShalom](#):
>
> Neither Github, nor our documentation highlights anything.

Nobody has implemented syntax highlighting for the Pkg REPL mode, so this is not surprising.

> [@ShalokShalom](#):
>
> And [highlight.js](https://github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md) does seem to alias julia-repl to julia, instead of considering it as its own syntax.

It is implemented by nesting regular Julia syntax within the `julia>` prompt. Other than that, Julia syntax in the REPL is no different from Julia syntax in files or wherever else, so I am not sure what you are missing here.

---

<div class="post-metadata">

**Author:** ![g-gundam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/g-gundam/32/47593_2.png) [@g-gundam](https://discourse.julialang.org/u/g-gundam)\
**Post date:** [October 3, 2023, 9:38pm UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/7 "2023-10-03T21:38:21Z")

</div>

Maybe someone who has admin access to this forum can add a little bit of custom CSS.

```css
span.hljs-meta.prompt_ {
  color: #17f117;
}

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/c/0c8d25c5b2b7c091e624faa04fbaa06a511f91cb.png)

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [October 3, 2023, 10:28pm UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/8 "2023-10-03T22:28:28Z")

</div>

Awesome, thanks! My above post is now much more snazzy! How’s the contrast of `#17f117` on light mode?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/3/13b4cc4b09b508456a9df28f1700ec2c7b626e67.png)

Edit: to answer my own question, it looks a little bright… suggestions on another color?

![image](https://global.discourse-cdn.com/julialang/original/3X/b/3/b37ab9cf3e0183d374ab718eedb32409ee0dd83d.png)

---

<div class="post-metadata">

**Author:** ![g-gundam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/g-gundam/32/47593_2.png) [@g-gundam](https://discourse.julialang.org/u/g-gundam)\
**Post date:** [October 3, 2023, 10:48pm UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/9 "2023-10-03T22:48:48Z")

</div>

I just realized there was a theme switcher on the bottom-left corner, and there are a lot of light colored themes. I had only ever seen the dark theme here until today. I picked a new darker green that looks OK to me in both dark and light themes. (I picked green, because the Julia REPL gives me a green `julia> ` prompt by default.)

# `#1d9a1d`

 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/7/17b86ed32b6ff1c6d41252184a726336d536651a.png)

---

<div class="post-metadata">

**Author:** ![ShalokShalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shalokshalom/32/52462_2.png) [@ShalokShalom](https://discourse.julialang.org/u/ShalokShalom)\
**Post date:** [October 4, 2023, 2:31am UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/10 "2023-10-04T02:31:11Z")

</div>

> [@fredrikekre](#):
>
> Nobody has implemented syntax highlighting for the Pkg REPL mode, so this is not surprising.

But why did someone then use the tag `julia-repl`? I anticipation for an implementation?

> [@fredrikekre](#):
>
> It is implemented by nesting regular Julia syntax within the `julia>` prompt. Other than that, Julia syntax in the REPL is no different from Julia syntax in files or wherever else, so I am not sure what you are missing here.

Äähm. No matter how small the difference, there is one. And aliasing one to the other, gives no other result. So, calling julia-repl will always call the normal highlighting, as is.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 4, 2023, 6:36am UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/11 "2023-10-04T06:36:02Z")

</div>

> [@ShalokShalom](#):
>
> But why did someone then use the tag `julia-repl`? I anticipation for an implementation?

Because even highlighting with the wrong highlighter can sometimes give some color/flavor to the text, but not in this example.

> [@ShalokShalom](#):
>
> No matter how small the difference, there is one.

What is the difference?

---

<div class="post-metadata">

**Author:** ![ShalokShalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shalokshalom/32/52462_2.png) [@ShalokShalom](https://discourse.julialang.org/u/ShalokShalom)\
**Post date:** [October 4, 2023, 7:09am UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/12 "2023-10-04T07:09:31Z")

</div>

> [@fredrikekre](#):
>
> Because even highlighting with the wrong highlighter can sometimes give some color/flavor to the text, but not in this example.

And how does this make any sense? Using a mode, that’s not working? I assume it worked at some point, or the committer thought, it might get supported at some point.

Among other things, it breaks on the prompt.

If I change the highlighting to `julia` this is the result:

![Screenshot_20231004_085741](https://global.discourse-cdn.com/julialang/original/3X/f/1/f1aae0d80bc8eafba79a54a6e91ad43ad36f6397.png)

And I don’t know if that is on purpose:

![Screenshot_20231004_085553](https://global.discourse-cdn.com/julialang/original/3X/e/0/e0d80a89f4553c4737f7000630df2c8e305e24b4.png)

But that is not the point. GitHub, the Documentation, and probably other sources are not applying `julia-repl`, so this is an issue. It seems to work on Discourse.

And aliasing two different modes is just wrong. It defeats the entire point of having distinct modes in the first place.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 4, 2023, 7:19am UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/13 "2023-10-04T07:19:23Z")

</div>

> [@ShalokShalom](#):
>
> And how does this make any sense? Using a mode, that’s not working? I assume it worked at some point, or the committer thought, it might get supported at some point.

Feel free to contribute by removing the language tags.

> [@ShalokShalom](#):
>
> Among other things, it breaks on the prompt.

What do you mean? As demonstrated above it _doesn’t_ break on the prompt, on the contrary, the prompt is detected and classified as a prompt.

> [@ShalokShalom](#):
>
> GitHub

GitHub uses a different highlighter, and the documents are not written for GitHub.

> [@ShalokShalom](#):
>
> And aliasing two different modes is just wrong. It defeats the entire point of having distinct modes in the first place.

Again, they are not just aliased. `julia-repl` does prompt detection for `julia>` and then the inner content is highlighted with the regular `julia` highlighter, as it should. Do you have an example where this doesn’t work?

---

<div class="post-metadata">

**Author:** ![ShalokShalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shalokshalom/32/52462_2.png) [@ShalokShalom](https://discourse.julialang.org/u/ShalokShalom)\
**Post date:** [October 4, 2023, 7:37am UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/14 "2023-10-04T07:37:05Z")

</div>

> [@fredrikekre](#):
>
> Feel free to contribute by removing the language tags.

I would rather care, that julia-repl works. And I was not sure, where this is implemented, so that I could link to it in an issue that I would raise. So I thought I ask here, first. 🙂

> [@fredrikekre](#):
>
> Again, they are not just aliased. `julia-repl` does prompt detection for `julia>` and then the inner content is highlighted with the regular `julia` highlighter, as it should. Do you have an example where this doesn’t work?

Again, it does on [highlight.js:](https://github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md)

![Screenshot_20231004_093552](https://global.discourse-cdn.com/julialang/original/3X/d/5/d5d627448c18fe2568268ad1bca0a02843e77491.png)  
 ![Screenshot_20231004_093618](https://global.discourse-cdn.com/julialang/original/3X/1/c/1c3a9077966ed0d7b777519d1fdd20f109f8369a.png)

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 4, 2023, 7:39am UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/15 "2023-10-04T07:39:22Z")

</div>

> [@ShalokShalom](#):
>
> Again, it does on [highlight.js:](https://github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md)

Thats just very confusing documentation, but what they mean is that for the language Julia there are two “flavors” (`julia` and `julia-repl`). The implementation of `julia-repl` is here: [https://github.com/highlightjs/highlight.js/blob/58dc5961f6f2bb8bc8bb1e7ce39f268a2fdd874f/src/languages/julia-repl.js](https://github.com/highlightjs/highlight.js/blob/58dc5961f6f2bb8bc8bb1e7ce39f268a2fdd874f/src/languages/julia-repl.js)

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [October 8, 2023, 3:27pm UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/16 "2023-10-08T15:27:18Z")

</div>

Feels like the Julia highlighting mode could ideally detect REPL syntax and change its rules. But not sure how feasible that would be.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [July 28, 2025, 2:37pm UTC](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/17 "2025-07-28T14:37:01Z")

</div>

Turns out this was _very trivial_. The default syntax we use here for un-adorned ````` blocks is now a custom language I’ve called [`julia-auto`](https://github.com/JuliaDiscourse/Unleashed-Julia-Syntax-Highlighting/blob/461aee7983db5a71c931cad14b16099bf15a5b6e/javascripts/discourse/api-initializers/theme-initializer.gjs#L683-L697).

So, yeah, you no longer need to explicitly enable this with `julia-repl`.
