Syntax Highlighting for Match-Case in Python

Hello! I noticed that the syntax highlighting for Python when viewing solutions on the web doesn’t include any highlights for match and case.

Here is an example image from the darts exercise, where they aren’t highlighted:

Solution

image

Also, here is my solution for the exercise so you can see it in your own browser. This is the same code as the image I provided earlier.

Although I don’t use the editor, match and case aren’t highlighted there either. I find it easier to read code with syntax highlighting. Would it be possible to add syntax highlighting for match and case?

I believe Exercism’s web editor relies on Highlight.js for syntax highlighting. Once that project is updated to support match/case, Exercism could bump their package version to get the latest and greatest.

Do you know if Highlight.js supports match/case highlighting? If not, you could potentially contribute it to that project!

It seems that support for match/case in Python was added awhile ago for Highlight.js as seen here.

There is also a demo on the official website in which match and case are treated as keywords whereas in Exercism it seems they are not.

Here is what I see when using the code in my initial post in the demo:

Syntax Highlight Example

I’m not familiar with Highlight.js or how it works, so there is a good chance I am confused.

If Highlight.js supports it, Exercism may need to update what version of the Highlight.js library they’re using. I’m not entirely sure how that works. It might be this line, though.

@iHiD Is there any process in place for bumping Highlight.js versions?

@dem4ron will update it when requested. Aron could you take a look pls?

The actual version(s) that are in use are here.

1 Like

This PR will update highlight.js:

3 Likes