Type highlighting for C# code blocks


I’m hoping to find out if there is a way to enable more granular highlighting for C# code blocks. Here’s what a code block looks like to me when rendered by Hugo v0.101.0:

Notice how type names (e.g. SceneView) are displayed in the same way as regular identifiers.

I don’t think this is a stylesheet issue. If I switch off noClasses and observe the resulting HTML, both type names and regular variable names are assigned the n class, which means that the highlighter seems to classify both kinds of identifiers as syntactically the same.

By contrast, other highlighters seem to know the difference between these. For example, VSCode’s highlighter is much richer: it distinguishes between type names, regular names, and new declarations. Here’s the same block of code from the source Markdown as it appears in my editor (sorry for no embed…I could only attach one image to this post).

Is this a configuration issue, or just a constraint of Hugo’s built-in highlighter? I’m curious if anyone else gets different results with similar C# code.

Thanks in advance!

We use the Chroma syntax highlighter. There’s a related open issue:

1 Like

I very much appreciate the link. That pretty much settles it!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.