# No syntax highlighting here?

**URL:** <https://discourse.julialang.org/t/no-syntax-highlighting-here/106674>\
**Category:** Meta Discussion\
**Created:** [November 24, 2023, 12:02pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674 "2023-11-24T12:02:25Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [November 24, 2023, 12:02pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674/1 "2023-11-24T12:02:25Z")

</div>

It is only me, or the site is not highlighting the code now?

```julia
function test(x)
    return x + 1
end

```

---

<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:** [November 24, 2023, 12:15pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674/2 "2023-11-24T12:15:01Z")

</div>

These errors from the browser console is probably related:

```julia
13:13:57.974 Failed to load ‘https://sea2.discourse-cdn.com/julialang/highlight-js/discourse.julialang.org/7799cdd24ca11b15d7a8a85f981da0edd8e1b9bb.js’. A ServiceWorker passed a promise to FetchEvent.respondWith() that rejected with ‘Error: no-response :: [{"url":"https://sea2.discourse-cdn.com/julialang/highlight-js/discourse.julialang.org/7799cdd24ca11b15d7a8a85f981da0edd8e1b9bb.js"}]’. workbox-core.prod.js:2:86
13:13:57.974 Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://sea2.discourse-cdn.com/julialang/highlight-js/discourse.julialang.org/7799cdd24ca11b15d7a8a85f981da0edd8e1b9bb.js. (Reason: CORS request did not succeed). Status code: (null).
13:13:57.974 Module source URI is not allowed in this document: “https://sea2.discourse-cdn.com/julialang/highlight-js/discourse.julialang.org/7799cdd24ca11b15d7a8a85f981da0edd8e1b9bb.js”. 106674:41:141

```

---

<div class="post-metadata">

**Author:** ![devel-chm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/devel-chm/32/3572_2.png) [@devel-chm](https://discourse.julialang.org/u/devel-chm)\
**Post date:** [November 24, 2023, 1:58pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674/3 "2023-11-24T13:58:46Z")

</div>

I’m not seeing any highlighting either.

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [November 24, 2023, 2:04pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674/4 "2023-11-24T14:04:25Z")

</div>

> [@fredrikekre](#):
>
> These errors from the browser console is probably related:

It’s this.  
Domain [discourse.julialang.org](http://discourse.julialang.org) sends header `strict-origin-when-cross-origin` which blocks the loadìng of `https://sea2.discourse-cdn.com/julialang/highlight-js/discourse.julialang.org/7799cdd24ca11b15d7a8a85f981da0edd8e1b9bb.js` as it is a different domain.

It needs a second header `Access-Control-Allow-Origin` configured properly.

---

<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:** [November 24, 2023, 4:03pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674/5 "2023-11-24T16:03:50Z")

</div>

Huh. Thanks for raising and identifying this; not sure how or why it regressed. I’ll look into it when I can.

---

<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:** [November 28, 2023, 1:49pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674/7 "2023-11-28T13:49:38Z")

</div>

This should now be fixed, thanks to the Discourse hosting team!

```julia-repl
julia> struct T; end # works!

```

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [November 28, 2023, 2:16pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674/8 "2023-11-28T14:16:07Z")

</div>

Out of curiosity, what sort of highlighting is there supposed to be? My desktop browser (Chrome) shows no highlighting of any kind, and never has. So I at first didn’t even understand what this thread was about.

My phone browser actually does show some _very subtle_ highlighting, bold for keywords (I never noticed it before now, because it’s so subtle.) And then, the Julia prompt is actually green, which is the only highlighting I _have_ noticed.

What am I missing? Can someone paste an image of highlighted code for me to see? Is it only for mobile?  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/4/f4401d28a619fd8af57ee7de9baa06e73235c0e6.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:** [November 28, 2023, 2:18pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674/9 "2023-11-28T14:18:13Z")

</div>

This is what you should see on _all_ platforms. It’s not just a mobile thing.  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/6/9607fb01c9ff638a325a65512e56a8a7e61b4e80.png)

It’s not too dramatic, but keywords are bolded, some builtin types are blue, numbers are teal, strings are red, comments are italicized gray. Do you have any errors in your browser console?

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [November 28, 2023, 2:25pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674/10 "2023-11-28T14:25:43Z")

</div>

Yes, I seem to have several. Of interest there is

```julia
Access to fetch at 'https://sea2.discourse-cdn.com/julialang/highlight-js/discourse.julialang.org/a596e0a7f2acbeff6663f0d54f3c59b18313c645.js' from origin 'https://discourse.julialang.org' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'https://sea2.discourse-cdn.com' that is not equal to the supplied origin. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

```

```julia
Uncaught (in promise) no-response: no-response :: [{"url":"https://sea2.discourse-cdn.com/julialang/highlight-js/discourse.julialang.org/a596e0a7f2acbeff6663f0d54f3c59b18313c645.js"}]
    at u._handle (https://global.discourse-cdn.com/julialang/assets/workbox-77b0e3e0dd4773bcd6c7e74f302f7c69/workbox-strategies.prod.js:54:13)
    at async u.Rt (https://global.discourse-cdn.com/julialang/assets/workbox-77b0e3e0dd4773bcd6c7e74f302f7c69/workbox-strategies.prod.js:40:10)

```

---

<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:** [November 28, 2023, 2:26pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674/11 "2023-11-28T14:26:38Z")

</div>

That looks like you still have a stale cache — that’s the very problem we just fixed. Try clearing your caches and refreshing.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [November 28, 2023, 2:28pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674/12 "2023-11-28T14:28:51Z")

</div>

I tried doing that _just_ before you posted, and it works 😃

Oh well. It’s just that I _never_ saw any highlighting, so I didn’t even understand what the discussion was about. “There’s supposed to be highlighting? 🤨”

---

<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:** [November 28, 2023, 2:38pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674/13 "2023-11-28T14:38:12Z")

</div>

If anyone is interested in some CSS’ing, it’s all a matter of themeing. I’m always happy to take suggestions on this — see, e.g., [Adding support for `julia-repl` syntax highlighting - #7 by g-gundam](https://discourse.julialang.org/t/adding-support-for-julia-repl-syntax-highlighting/104357/7).

```julia-repl
julia> if a<1.2 || b=="s" && c in Dict(:a=>'f'); 1::Int end

```

The highlights.js library puts these classes on the above:

```html
<span class="hljs-meta prompt_">julia&gt;</span>
<span class="language-julia">
    <span class="hljs-keyword">if</span>
    a&lt;
    <span class="hljs-number">1.2</span>
    || b==
    <span class="hljs-string">"s"</span>
    &amp;&amp; c 
    <span class="hljs-keyword">in</span>
    <span class="hljs-built_in">Dict</span>
    (:a=&gt;
    <span class="hljs-string">'f'</span>
    ); 
    <span class="hljs-number">1</span>
    ::
    <span class="hljs-built_in">Int</span>
    <span class="hljs-keyword">end</span>
</span>

```

The HTML highlighting is much more colorful as its markup is so standard that it tags pretty much everything, including things that don’t make much sense in Julia’s syntax (e.g., tags, names, attrs, etc).

---

<div class="post-metadata">

**Author:** ![devel-chm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/devel-chm/32/3572_2.png) [@devel-chm](https://discourse.julialang.org/u/devel-chm)\
**Post date:** [November 28, 2023, 2:43pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674/14 "2023-11-28T14:43:50Z")

</div>

The highlighting colors are also a function of the color scheme  
selected in your Discourse preferences. A dark scheme gave me  
only monochrome highlights (bold, normal, grey, dark grey,…).  
Changing to a light scheme made the prompt get a color.

---

<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:** [November 28, 2023, 3:00pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674/15 "2023-11-28T15:00:56Z")

</div>

That’s a good point — and it’s also worth noting that while we ostensibly have five themes available for you to pick here, it’s mostly the default **Light Theme** and **Dark Theme** that have gotten the most care and attention.

---

<div class="post-metadata">

**Author:** ![mihalybaci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mihalybaci/32/13528_2.png) [@mihalybaci](https://discourse.julialang.org/u/mihalybaci)\
**Post date:** [November 28, 2023, 3:06pm UTC](https://discourse.julialang.org/t/no-syntax-highlighting-here/106674/16 "2023-11-28T15:06:20Z")

</div>

Thanks for this tip! I had my theme set to “graceful” and some, but not all the highlights. the `julia>` prompt didn’t show green, for example. I thought I was the odd one out here with weird highlighting. But switching back to light theme fixed it.
