Log in Sign up

Syntax Highlighting

Can you see any reason why the Syntax Highlighting for the Javascript section in this post isn't showing? It appears to be trying to load the colors according to the HTML when I inspect the element, but none of the syntax colors are working.

They were working earlier this evening.


2 years ago, 6 replies   Edit question

It looks like you removed the CSS required? The HTML output looks correct, it seems like the syntax highlighter plugin is behaving as expected

Answered 2 years ago · Edit answer

I've tried copying and pasting the original CSS in from another template, but no luck.

Answered 2 years ago · Edit answer

Look for the ‘.hljs’ CSS and make sure that is present in your custom template’s CSS file

Answered 2 years ago · Edit answer

Yep, copied directly from the Blog template's CSS:

But it's not pulling in that formatting: https://heydingus.net/blog/2021/11/writing-my-first-script

Answered 2 years ago · Edit answer

There's likely a syntax issue with your CSS or template code elsewhere in that file which is tanking the .hljs styles – I've confirmed that although the text string for the required CSS is present in style.css, per my browser's developer tools the styles themselves were not parsed. When I moved the hljs styles to the top of style.css for you, they are now parsed correctly which further supports this assumption.

Answered 2 years ago · Edit answer

Hmm, I guess I’ll need to do some spelunking to try to figure out what I messed up. But thanks for the move-to-top fix!

Answered 2 years ago · Edit answer