No syntax highlighting here?

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

function test(x)
    return x + 1
end
2 Likes

These errors from the browser console is probably related:

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
3 Likes

I’m not seeing any highlighting either.

It’s this.
Domain 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.

1 Like

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

10 Likes

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

julia> struct T; end # works!
9 Likes

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

This is what you should see on all platforms. It’s not just a mobile thing.
image

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?

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

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.
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)

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

1 Like

I tried doing that just before you posted, and it works :smiley:

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? :face_with_raised_eyebrow:

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.

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:

<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).

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.

1 Like

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.

1 Like

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.