Syntax highlighting is not working with C#

{{< highlight C# >}}

{{< /highlight >}}

This does not seem to work any help would be really appreciated

The hash sign and the space between highlight and C are breaking your shortcode. You should try removing them.

Go templates are very picky with special characters.

well I don’t want to put C because the code is C#…anything I can do?

Read up on Go templates syntax.

And this is not my shorcode. It’s a hugo shortcode for syntaxe highlighting. You should read up on syntax highlighting :

I haven’t experimented with Chroma yet, but I see it has a lexer for C#, as does Pygments. So the problem is it’s choking on the #, looks like. @stephenbe did you try escaping the #, or passing something like:






… to see if anything would work?

Try {{< highlight "C#" >}}.

I use Chroma for C# highlighting and it works great. Just use csharp as the name instead of C#:

foreach (DirectoryInfo folder in RootDirectory.EnumerateDirectories())

This works like a charm. I suspect the highlight shortcode also requires csharp rather than C#.

I don’t need to.

But back to your question as others have pointed out the hash is indeed the problem.

And the full Go templates documentation is not on the Hugo site.

It’s here:

@alexandros : I would appreciate you please not comment on threads on things you don’t understand. I appreciate that you tried though.

So these two solution worked for me :

{{< highlight “C#” >}}

{{< highlight charp >}}»

i also had to update my hugo.

Thank you @Jura and @moorereason :slight_smile:

In the future please refrain from posting your personal admonitions and assumptions in the forum.

Locking this.