Adding support for Razor syntax highlighting

Hi,

I’m using Hugo 0.115.2 and the hugo-blog-awesome theme.

I understand Hugo uses Chroma for syntax highlighting. I also understand that Hugo’s syntax highlighting can be configured.

Chroma does not appear to support Razor (.razor) syntax highlighting. Is it possible to add highlighting for that syntax on top of the highlighting already provided by Chroma?

Please clarify. Do you want to syntax highlight CSHTML files?

Hi,

Consider this Razor code block:
Shared/TableTemplate.razor

```
@typeparam TItem
@using System.Diagnostics.CodeAnalysis

<table class="table">
    <thead>
        <tr>@TableHeader</tr>
    </thead>
    <tbody>
        @foreach (var item in Items)
        {
            if (RowTemplate is not null)
            {
                <tr>@RowTemplate(item)</tr>
            }
        }
    </tbody>
</table>
@code {
    [Parameter]
    public RenderFragment? TableHeader { get; set; }

    [Parameter]
    public RenderFragment<TItem>? RowTemplate { get; set; }

    [Parameter, AllowNull]
    public IReadOnlyList<TItem> Items { get; set; }
}
```

This is what I’m trying to highlight.

Try the csharp lexer with styles such as :

  • emacs, friendly, igor, vs (light)
  • dracula, modus-vivendi (dark)

The closest Pygments lexer is aspx-cs (would need to be ported to Chroma), but the csharp lexer (included with Chroma) may be sufficient.

Also try the TypeScript lexer.