Detalhes do pacote

highlightjs-cshtml-razor

highlightjs4.7kCC0-1.02.2.0

highlight.js syntax definition for ASP.NET Razor CSHTML language

cshtml, cshtml-razor, cshtml-blazor, razor-cshtml

readme (leia-me)

CSHTML Razor - a language grammar for highlight.js

version license install size minified size

CSHTML is a markup language created by Microsoft for ASP.NET MVC, ASP.NET Core and Blazor applications. It allows to create markup containing both C# and HTML code.

For more about the CSHTML Razor syntax here: https://docs.microsoft.com/en-us/aspnet/core/mvc/views/razor.

Usage

Simply include the Highlight.js library in your webpage or Node app, then load this module.

Static website or simple usage

Simply load the module after loading Highlight.js. You'll use the minified version found in the dist directory. This module is just a CDN build of the language, so it will register itself as the Javascript is loaded.

<script type="text/javascript" src="/path/to/highlight.min.js"></script>
<script type="text/javascript" src="/path/to/highlightjs-cshtml-razor/dist/cshtml-razor.min.js"></script>
<script>
    hljs.highlightAll();
</script>

Using directly from the UNPKG CDN

Add the following script tag in your page:

<script type="text/javascript" src="https://unpkg.com/highlightjs-cshtml-razor/dist/cshtml-razor.min.js"></script>

With Node or another build system

If you're using Node / Webpack / Rollup / Browserify, etc, simply require the language module, then register it with Highlight.js.

var hljs = require('highlightjs');
var hljsRazor = require('highlightjs-cshtml-razor');

hljs.registerLanguage("cshtml-razor", hljsRazor);
hljs.highlightAll();

License

License: CC0-1.0

changelog (log de mudanças)

Changelog

All notable changes to this project will be documented in this file.

[2.2.0] - 2025-06-26

  • Fixed "Polynomial backtracking" vulnerability
  • Updated version of hljs

[2.1.2] - 2025-06-25

  • Fix incorrect processing '>' symbols inside strings in code blocks
  • Split tests to simplify its running

[2.1.0] - 2021-04-14

  • Add the dist directory, and a minified version of the script

[2.0.1] - 2021-03-02

Fixed

  • Fix inline razor blocks inside tag attributes (inside double quotes)

[2.0.0] - 2020-09-28

Added

  • Support the @code directives

    Changed

  • Update dependency on highlight.js (support 10.0)

[1.2.0] - 2019-09-13

Added

  • Support the @pages directive
  • Support razor comments

Changed

  • Update dependency on highlight.js