Skip to content
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

Up hljs version #16

Merged
merged 1 commit into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog
All notable changes to this project will be documented in this file.

## [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
Expand Down
22 changes: 11 additions & 11 deletions cshtml-razor.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function hljsDefineCshtmlRazor(hljs) {
begin: '@[A-Za-z0-9\\._:-]+',
returnBegin: true,
end: "(\\r|\\n|<|\\s|\"|')",
subLanguage: 'cs',
subLanguage: 'csharp',
contains: [
{
begin: '@',
Expand Down Expand Up @@ -165,7 +165,7 @@ function hljsDefineCshtmlRazor(hljs) {
end: "\\)",
returnBegin: true,
returnEnd: true,
subLanguage: 'cs',
subLanguage: 'csharp',
contains: [
{
begin: "@\\(",
Expand All @@ -174,7 +174,7 @@ function hljsDefineCshtmlRazor(hljs) {
{
begin: "\\(",
end: "\\)",
subLanguage: 'cs',
subLanguage: 'csharp',
contains: [hljs.QUOTE_STRING_MODE, 'self', razor_text_block]
},
razor_text_block,
Expand Down Expand Up @@ -215,7 +215,7 @@ function hljsDefineCshtmlRazor(hljs) {
variants: cs_code_block_variants,
returnBegin: true,
returnEnd: true,
subLanguage: 'cs',
subLanguage: 'csharp',
contains: [
{
begin: "@(code\\s*)?\\{",
Expand Down Expand Up @@ -251,7 +251,7 @@ function hljsDefineCshtmlRazor(hljs) {
variants: razor_code_block_variants,
returnBegin: true,
returnEnd: true,
subLanguage: 'cs',
subLanguage: 'csharp',
contains: [
{
variants: razor_code_block_variants.map(function (v) { return { begin: v.begin }; }),
Expand All @@ -260,7 +260,7 @@ function hljsDefineCshtmlRazor(hljs) {
{ begin: "@", className: SPECIAL_SYMBOL_CLASSNAME },
{
variants: razor_code_block_variants.map(function (v) { return { begin: v.begin.substr(1, v.begin.length - 2) }; }),
subLanguage: 'cs'
subLanguage: 'csharp'
},
{ begin: "{", className: SPECIAL_SYMBOL_CLASSNAME }
]
Expand All @@ -279,7 +279,7 @@ function hljsDefineCshtmlRazor(hljs) {
{ begin: "[\\s]*else\\sif[\\s]*\\([^{]+[\\s]*{" },
{ begin: "[\\s]*else[\\s]*" }
],
subLanguage: 'cs'
subLanguage: 'csharp'
},
{
begin: "{",
Expand All @@ -296,10 +296,10 @@ function hljsDefineCshtmlRazor(hljs) {
end: "}",
returnBegin: true,
returnEnd: true,
subLanguage: 'cs',
subLanguage: 'csharp',
contains: [
{ begin: "@", className: SPECIAL_SYMBOL_CLASSNAME },
{ begin: "try[\\s]*{", subLanguage: 'cs' },
{ begin: "try[\\s]*{", subLanguage: 'csharp' },
{
variants: [
{ begin: "}[\\s]*catch[\\s]*\\([^\\)]+\\)[\\s]*{" },
Expand All @@ -313,7 +313,7 @@ function hljsDefineCshtmlRazor(hljs) {
{ begin: "[\\s]*catch[\\s]*\\([^\\)]+\\)[\\s]*", },
{ begin: "[\\s]*finally[\\s]*", },
],
subLanguage: 'cs'
subLanguage: 'csharp'
},
{ begin: "{", className: SPECIAL_SYMBOL_CLASSNAME }
]
Expand Down Expand Up @@ -342,7 +342,7 @@ function hljsDefineCshtmlRazor(hljs) {
var rasor_await = {
begin: "@await ",
returnBegin: true,
subLanguage: 'cs',
subLanguage: 'csharp',
end: "(\\r|\\n|<|\\s)",
contains: [
{
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "highlightjs-cshtml-razor",
"version": "1.3.0",
"version": "2.0.0",
"description": "highlight.js syntax definition for ASP.NET Razor CSHTML language",
"main": "cshtml-razor.js",
"scripts": {
Expand Down Expand Up @@ -33,7 +33,7 @@
},
"homepage": "https://github.com/highlightjs/highlightjs-cshtml-razor#readme",
"devDependencies": {
"highlight.js": "^9.15.10",
"highlight.js": "^10.0.0",
"mocha": "^5.2.0",
"should": "^13.2.3"
},
Expand Down
12 changes: 6 additions & 6 deletions test/markup/code-block-multiline.expect.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
before
<span class="cs"></span><span class="hljs-built_in">@{</span><span class="cs">
<span class="hljs-built_in">@{</span><span class="csharp">
<span class="hljs-keyword">var</span> inCSharp = <span class="hljs-literal">true</span>;
</span><span class="cshtml-razor"></span><span class="hljs-built_in">&lt;text&gt;</span><span class="cshtml-razor">xml</span><span class="hljs-built_in">&lt;/text&gt;</span><span class="cs">
</span><span class="hljs-built_in">&lt;text&gt;</span><span class="cshtml-razor">xml</span><span class="hljs-built_in">&lt;/text&gt;</span><span class="csharp">
</span><span class="hljs-built_in">}</span>
after
<span class="cs"></span><span class="hljs-built_in">@{</span><span class="cs">
<span class="hljs-built_in">@{</span><span class="csharp">
<span class="hljs-keyword">var</span> inCSharp = <span class="hljs-literal">true</span>;
</span><span class="cshtml-razor"></span><span class="hljs-built_in">&lt;text&gt;</span><span class="cshtml-razor">xml</span><span class="hljs-built_in">&lt;/text&gt;</span><span class="cs">
</span><span class="hljs-built_in">&lt;text&gt;</span><span class="cshtml-razor">xml</span><span class="hljs-built_in">&lt;/text&gt;</span><span class="csharp">
</span><span class="hljs-built_in">}</span>


code:
<span class="cs"></span><span class="hljs-built_in">@code {</span><span class="cs">
<span class="hljs-built_in">@code {</span><span class="csharp">
<span class="hljs-keyword">var</span> inCSharp = <span class="hljs-literal">true</span>;
</span><span class="cshtml-razor"></span><span class="hljs-built_in">&lt;text&gt;</span><span class="cshtml-razor">xml</span><span class="hljs-built_in">&lt;/text&gt;</span><span class="cs">
</span><span class="hljs-built_in">&lt;text&gt;</span><span class="cshtml-razor">xml</span><span class="hljs-built_in">&lt;/text&gt;</span><span class="csharp">
</span><span class="hljs-built_in">}</span>
4 changes: 2 additions & 2 deletions test/markup/if-else-block.expect.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
before
<span class="cs"></span><span class="hljs-built_in">@</span><span class="cs"><span class="hljs-keyword">if</span>(<span class="hljs-literal">true</span>) </span><span class="hljs-built_in">{</span><span class="cs">
<span class="hljs-built_in">@</span><span class="csharp"><span class="hljs-keyword">if</span>(<span class="hljs-literal">true</span>) </span><span class="hljs-built_in">{</span><span class="csharp">
block
</span><span class="hljs-built_in">}</span><span class="cs"> <span class="hljs-keyword">else</span> </span><span class="hljs-built_in">{</span><span class="cs">
</span><span class="hljs-built_in">}</span><span class="csharp"> <span class="hljs-keyword">else</span> </span><span class="hljs-built_in">{</span><span class="csharp">
block
</span><span class="hljs-built_in">}</span>
after
10 changes: 5 additions & 5 deletions test/markup/inline.expect.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Hello <span class="cs"></span><span class="hljs-built_in">@</span><span class="cs">owner</span> from html
Hello <span class="cs"></span><span class="hljs-built_in">@</span><span class="cs">owner[<span class="hljs-string">"test"</span>]</span> from html
Hello <span class="cs"></span><span class="hljs-built_in">@</span><span class="cs">owner.test</span> from html
Hello <span class="cs"></span><span class="hljs-built_in">@</span><span class="cs">owner</span><span class="hljs-tag">&lt;<span class="hljs-name">b</span>&gt;</span>from html<span class="hljs-tag">&lt;/<span class="hljs-name">b</span>&gt;</span>
Hello <span class="cs"></span><span class="hljs-built_in">@</span><span class="cs">owner</span>
Hello <span class="hljs-built_in">@</span><span class="csharp">owner</span> from html
Hello <span class="hljs-built_in">@</span><span class="csharp">owner[<span class="hljs-string">&quot;test&quot;</span>]</span> from html
Hello <span class="hljs-built_in">@</span><span class="csharp">owner.test</span> from html
Hello <span class="hljs-built_in">@</span><span class="csharp">owner</span><span class="hljs-tag">&lt;<span class="hljs-name">b</span>&gt;</span>from html<span class="hljs-tag">&lt;/<span class="hljs-name">b</span>&gt;</span>
Hello <span class="hljs-built_in">@</span><span class="csharp">owner</span>
from html
sample@email.com
@@escapedat
18 changes: 9 additions & 9 deletions test/markup/razor-in-razor.expect.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<span class="cs"></span><span class="hljs-built_in">@{</span><span class="cs">
<span class="hljs-built_in">@{</span><span class="csharp">
<span class="hljs-keyword">var</span> inCSharp = <span class="hljs-literal">true</span>;
</span><span class="cshtml-razor"></span><span class="hljs-built_in">@&lt;text&gt;</span><span class="cshtml-razor">xml</span><span class="hljs-built_in">&lt;/text&gt;</span><span class="cs">
</span><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"foo"</span>&gt;</span><span class="cs">content</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><span class="cs">
</span><span class="hljs-built_in">@&lt;text&gt;</span><span class="cshtml-razor">xml</span><span class="hljs-built_in">&lt;/text&gt;</span><span class="csharp">
</span><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;foo&quot;</span>&gt;</span><span class="csharp">content</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><span class="csharp">
</span><span class="hljs-built_in">}</span>

<span class="cs"></span><span class="hljs-built_in">@</span><span class="cs"><span class="hljs-keyword">if</span>(<span class="hljs-literal">true</span>)</span><span class="hljs-built_in">{</span><span class="cs">
<span class="hljs-built_in">@</span><span class="csharp"><span class="hljs-keyword">if</span>(<span class="hljs-literal">true</span>)</span><span class="hljs-built_in">{</span><span class="csharp">
<span class="hljs-keyword">var</span> inCSharp = <span class="hljs-literal">true</span>;
</span><span class="cshtml-razor"></span><span class="hljs-built_in">@&lt;text&gt;</span><span class="cshtml-razor">xml</span><span class="hljs-built_in">&lt;/text&gt;</span><span class="cs">
</span><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"foo"</span>&gt;</span><span class="cs">content</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><span class="cs">
</span><span class="hljs-built_in">@&lt;text&gt;</span><span class="cshtml-razor">xml</span><span class="hljs-built_in">&lt;/text&gt;</span><span class="csharp">
</span><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;foo&quot;</span>&gt;</span><span class="csharp">content</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><span class="csharp">
</span><span class="hljs-built_in">}</span>

<span class="cshtml-razor"></span><span class="hljs-built_in">@section Test{</span><span class="cshtml-razor">
<span class="hljs-built_in">@section Test{</span><span class="cshtml-razor">
var inCSharp = true;
<span class="cshtml-razor"></span><span class="hljs-built_in">@&lt;text&gt;</span><span class="cshtml-razor">xml</span><span class="hljs-built_in">&lt;/text&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"foo"</span>&gt;</span>content<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-built_in">@&lt;text&gt;</span><span class="cshtml-razor">xml</span><span class="hljs-built_in">&lt;/text&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;foo&quot;</span>&gt;</span>content<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</span><span class="hljs-built_in">}</span>