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.