Skip to content

Commit 6476f8b

Browse files
committed
Add dist folder
1 parent 808c3ec commit 6476f8b

File tree

7 files changed

+60
-33
lines changed

7 files changed

+60
-33
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [2.1.0] - 2021-04-14
5+
- Add the dist directory, and a minified version of the script
6+
47
## [2.0.1] - 2021-03-02
58
### Fixed
69
- Fix inline razor blocks inside tag attributes (inside double quotes)

README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,39 @@ CSHTML is a markup language created by Microsoft for ASP.NET MVC and ASP.NET Cor
66

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

9-
### Usage
9+
## Usage
1010

11-
Simply include the `highlight.js` script package in your webpage or node app, load up this module and apply it to `hljs`.
11+
Simply include the `Highlight.js` library in your webpage or Node app, then load this module.
1212

13-
If you're not using a build system and just want to embed this in your webpage:
13+
### Static website or simple usage
14+
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.
1415

1516
```html
16-
<script src="/path/to/highlight.js/highlight.pack.js"></script>
17-
<script src="/path/to/highlightjs-cshtml-razor/cshtml-razor.js"></script>
17+
<script type="text/javascript" src="/path/to/highlight.min.js"></script>
18+
<script type="text/javascript" src="/path/to/highlightjs-cshtml-razor/dist/cshtml-razor.min.js"></script>
1819
<script>
1920
hljs.registerLanguage('cshtml-razor', window.hljsDefineCshtmlRazor);
2021
hljs.initHighlightingOnLoad();
2122
</script>
2223
```
2324

24-
If you're using webpack / rollup / browserify / node:
25+
### Using directly from the UNPKG CDN
26+
27+
Add the following script tag in your page:
28+
29+
```html
30+
<script type="text/javascript" src="https://unpkg.com/highlightjs-cshtml-razor/dist/cshtml-razor.min.js"></script>
31+
```
32+
33+
### With Node or another build system
34+
35+
If you're using Node / Webpack / Rollup / Browserify, etc, simply require the language module, then register it with Highlight.js.
2536

2637
```javascript
27-
var hljs = require('highlight.js');
28-
var hljsDefineCshtmlRazor = require('highlightjs-cshtml-razor');
38+
var hljs = require('highlightjs');
39+
var hljsRazor = require('highlightjs-cshtml-razor');
2940

30-
hljsDefineCshtmlRazor(hljs);
41+
hljs.registerLanguage("highlightjs-cshtml-razor", hljsRazor);
3142
hljs.initHighlightingOnLoad();
3243
```
3344

package-lock.json

Lines changed: 11 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "highlightjs-cshtml-razor",
3-
"version": "2.0.1",
3+
"version": "2.1.0",
44
"description": "highlight.js syntax definition for ASP.NET Razor CSHTML language",
5-
"main": "cshtml-razor.js",
5+
"main": "src/cshtml-razor.js",
66
"scripts": {
77
"test": "./node_modules/.bin/mocha --reporter spec"
88
},
@@ -37,5 +37,7 @@
3737
"mocha": "^5.2.0",
3838
"should": "^13.2.3"
3939
},
40-
"dependencies": {}
40+
"dependencies": {
41+
"minimist": "^1.2.5"
42+
}
4143
}

cshtml-razor.js renamed to src/cshtml-razor.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,15 @@ function hljsDefineCshtmlRazor(hljs) {
189189
]
190190
};
191191
var xml_blocks = getXmlBlocks(hljs, [razor_inline_expresion, razor_parentheses_block]);
192+
var razor_directives_prefix = "^\\s*@(page|model|using|inherits|inject|layout)";
192193
var razor_directives = {
193-
begin: "^\\s*@(page|model|using|inherits|inject)[^\\r\\n{\\(]*$",
194+
begin: razor_directives_prefix + "[^\\r\\n{\\(]*$",
194195
end: "$",
195196
returnBegin: true,
196197
returnEnd: true,
197198
contains: [
198199
{
199-
begin: "^\\s*@(page|model|using|inherits|inject)",
200+
begin: razor_directives_prefix,
200201
className: SPECIAL_SYMBOL_CLASSNAME
201202
},
202203
{

test/index.html

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<title></title>
1010
<meta name="description" content="">
1111
<meta name="viewport" content="width=device-width, initial-scale=1">
12-
<link rel="stylesheet" href="../node_modules/highlightjs/styles/default.css">
13-
<script type="text/javascript" src="../node_modules/highlightjs/highlight.pack.js"></script>
12+
<link rel="stylesheet" href="../node_modules/highlight.js/styles/default.css">
13+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js"></script>
1414
<script type="text/javascript" src="../cshtml-razor.js"></script>
1515
<script type="text/javascript">
1616
hljs.registerLanguage('cshtml-razor', window.hljsDefineCshtmlRazor);
@@ -19,18 +19,21 @@
1919
</head>
2020
<body>
2121
<pre><code class="hljs cshtml">
22-
before
23-
@{
24-
var inCSharp = true;
25-
@&lt;text&gt;xml&lt;/text&gt;
26-
&lt;div class="foo"&gt;content&lt;/div&gt;
27-
}
28-
after
29-
@{
30-
var inCSharp = true;
31-
&lt;text&gt;xml&lt;/text&gt;
32-
}
33-
&lt;div class="foo"&gt;content&lt;/div&gt;
22+
@using System.Threading
23+
@using System.Threading.Tasks
24+
@using System.Net.Http
25+
@using System.Text.Json
26+
&lt;DxDataGrid T="@WebApiOrder" CustomData="@LoadOrderData("foo")" ShowFilterRow="true"&gt;
27+
&lt;Columns&gt;
28+
&lt;DxDataGridComboBoxColumn T="@(WebApiCustomerLookup)" TextFieldName="Text" ValueFieldName="Value"
29+
CustomData="@LoadCustomerData" Field="@nameof(WebApiOrder.CustomerID)" Width="300px" /&gt;
30+
&lt;DxDataGridDateEditColumn Field="@nameof(WebApiOrder.OrderDate)" Width="180px" /&gt;
31+
&lt;DxDataGridSpinEditColumn Field="@nameof(WebApiOrder.Freight)" DisplayFormat="c" Width="180px" /&gt;
32+
&lt;DxDataGridColumn Field="@nameof(WebApiOrder.ShipCountry)" Width="210px" /&gt;
33+
&lt;DxDataGridComboBoxColumn T="@(WebApiShipperLookup)" TextFieldName="Text" ValueFieldName="Value"
34+
CustomData="@LoadShipmentData" Field="@nameof(WebApiOrder.ShipVia)" Width="220px" /&gt;
35+
&lt;/Columns&gt;
36+
&lt;/DxDataGrid&gt;
3437
</code></pre>
3538
<pre><code class="hljs cshtml">
3639
@if(true) {

test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var promisify = require("util").promisify;
33
let path = require('path');
44
let hljs = require("highlight.js");
55
const fs = require("fs");
6-
let hljsDefineCshtmlRazor = require("../cshtml-razor");
6+
let hljsDefineCshtmlRazor = require("../src/cshtml-razor");
77

88
const readdir = promisify(fs.readdir),
99
readFile = promisify(fs.readFile);

0 commit comments

Comments
 (0)