The code highlighting here on Stack Overflow appears to be missing a tag for Blazor-like pages where C# and HTML are combined within the same file.
Currently, I can only format it as either C# or HTML. Is there a way to combine C# and HTML highlighting and format these code snippets?
Formatted as HTML:
@page
@model Kommunikator.Api.Pages.OptionsModel
@{
ViewData["Title"] = "Options";
string tableBorderColor = "#777";
}
<h1>Übersicht</h1>
<div class="w3-row-padding w3-stretch">
<div class="w3-third">
<h2>Options</h2>
<table class="w3-small" style="width: 100%; border: 1px solid @tableBorderColor; border-collapse: collapse">
<tr>
<td colspan="2" style="font-weight: bold" class="w3-pale-blue">@validations.Name</td>
</tr>
@foreach (Kommunikator.Core.Application.ActionResult reason in validations.Results)
{
<tr style="border: 1px solid @tableBorderColor">
<td class="@OptionsModel.StatusZuFarbe(reason)" style="border-right: 1px solid @tableBorderColor">@OptionsModel.StatusZuText(reason)</td>
<td style="padding-left: 5px">@reason.Message</td>
</tr>
}
}
</table>
</div>
</div>
Formatted in C#:
@page
@model Kommunikator.Api.Pages.OptionsModel
@{
ViewData["Title"] = "Options";
string tableBorderColor = "#777";
}
<h1>Übersicht</h1>
<div class="w3-row-padding w3-stretch">
<div class="w3-third">
<h2>Options</h2>
<table class="w3-small" style="width: 100%; border: 1px solid @tableBorderColor; border-collapse: collapse">
<tr>
<td colspan="2" style="font-weight: bold" class="w3-pale-blue">@validations.Name</td>
</tr>
@foreach (Kommunikator.Core.Application.ActionResult reason in validations.Results)
{
<tr style="border: 1px solid @tableBorderColor">
<td class="@OptionsModel.StatusZuFarbe(reason)" style="border-right: 1px solid @tableBorderColor">@OptionsModel.StatusZuText(reason)</td>
<td style="padding-left: 5px">@reason.Message</td>
</tr>
}
}
</table>
</div>
</div>
In Visual Studio there is proper syntax highlighting for the HTML and C# parts of the code:
