-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect syntax highlighting of cshtml files in GitHub #3760
Comments
The Are all |
No ordinary C# files use that file extension. |
I second this. Razor, like other view engines, uses a syntax that's kind of a hybrid of HTML and an actual programming language--in this case, C#. So neither HTML nor C# is an appropriate language tag for Razor code in Github comments, issues, etc. |
Visual Studio Code editor already has grammars that are needed to correctly highlight cshtml files. The grammars are located in Visual Studio Code syntaxes folder and are fully compatible with Atom & Github parsing engines as far as I know. So why not to take production-ready highlighters from there? atom/language-csharp repository already uses Microsoft's grammar (but packages don't seem to be uploaded to Atom and Github yet), so this can be done with cshtml too. @Alhadis hope this helps! |
The For example: @if (User.Identity.IsAuthenticated)
{
<ul class="nav navbar-nav navbar-right">
<li><a asp-controller="Account" asp-action="Signout">Sign out</a></li>
</ul>
}
else
{
<ul class="nav navbar-nav navbar-right">
<li><a asp-controller="Account" asp-action="Signin">Sign in</a></li>
</ul>
} Where <img width="20" height="20" class="avatar" alt="@User.Identity.Name" src="@User.Claims.FirstOrDefault(c => c.Type == "picture")?.Value"> Check Microsoft Docs for more details about Razor syntax. |
This issue has been automatically marked as stale because it has not had activity in a long time. If this issue is still relevant and should remain open, please reply with a short explanation (e.g. "I have checked the code and this issue is still relevant because ___."). Thank you for your contributions. |
This issue is still relevant as the linguist languages.yml file still considers the |
Worth using |
Does one of you want to open a pull request to implement this change (move |
Closing as this is resolved by #4314. |
Looks like there are still some issues that have resulted following this, example here: https://gist.github.com/dazbradbury/2526da9ee866628ee10a0f2a4829253d Previously, the red error highlighting wouldn't appear. |
@dazbradbury That's going to be a problem with the grammar itself and easily reproducible by checking it directly within Lightshow. You'll need to raise an issue against the grammar itself for this to be resolved. Once the grammar has resolved the issue, the change will automatically be pulled in in the next release of Linguist after it's fixed in the grammar. |
@dazbradbury the grammar used for |
if this was fixed at some point - cshtml is now being considered as html again - and i agree with others, that it should de it's own categorized language because it isn't actually either of those languages |
@alphonso77 This isn't a Linguist issue. This is an issue with the grammar. If you wish to have it resolved, you need to log an issue with the grammar. |
@lildude, I'm sorry - I saw the comment earlier stating that, it was just a moment of frustration. |
Razor pages (i.e. those with an extension of
.cshtml
) are syntax highlighted using the C# syntax highlighter. However, the vast majority of a Razor page is HTML instead of C#, and the syntax highlighting of the HTML part is either absent or completely wrong. Not only that, but many of the at-directives are not correctly syntax highlighted.(see https://github.com/infinnie/TodoServer/blob/master/TodoServer/Views/Todos/Index.cshtml )
The text was updated successfully, but these errors were encountered: