Skip to content

Commit 808c3ec

Browse files
committed
fix inline blocks inside attributes
1 parent e13ee73 commit 808c3ec

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed

CHANGELOG.md

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

4+
## [2.0.1] - 2021-03-02
5+
### Fixed
6+
- Fix inline razor blocks inside tag attributes (inside double quotes)
7+
48
## [2.0.0] - 2020-09-28
59
### Added
610
- Support the @code directives

cshtml-razor.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,15 @@ function hljsDefineCshtmlRazor(hljs) {
124124
className: SPECIAL_SYMBOL_CLASSNAME
125125
},
126126
{
127-
begin: '".*(?!$)"',
127+
begin: '\\[',
128+
end: '\\]',
128129
skip: true
129-
},
130+
}
131+
,
130132
{
131-
begin: '"',
132-
endsParent: true
133+
begin: '\\(',
134+
end: '\\)',
135+
skip: true
133136
}
134137
],
135138
returnEnd: true

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "highlightjs-cshtml-razor",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "highlight.js syntax definition for ASP.NET Razor CSHTML language",
55
"main": "cshtml-razor.js",
66
"scripts": {

test/markup/inline.expect.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ Hello <span class="hljs-built_in">@</span><span class="csharp">owner</span><span
55
Hello <span class="hljs-built_in">@</span><span class="csharp">owner</span>
66
from html
77
8-
@@escapedat
8+
@@escapedat
9+
10+
<span class="hljs-tag">&lt;<span class="hljs-name">DxDataGrid</span> <span class="hljs-attr">T</span>=<span class="hljs-string">&quot;<span class="hljs-built_in">@</span><span class="csharp">WebApiOrder</span>&quot;</span> <span class="hljs-attr">CustomData</span>=<span class="hljs-string">&quot;<span class="hljs-built_in">@</span><span class="csharp">LoadOrderData(<span class="hljs-string">&quot;foo&quot;</span>)</span>&quot;</span> <span class="hljs-attr">ShowFilterRow</span>=<span class="hljs-string">&quot;true&quot;</span> <span class="hljs-attr">SuperDuper</span>=<span class="hljs-string">&quot;<span class="hljs-built_in">@</span><span class="csharp">Foo[<span class="hljs-string">&quot;bar&quot;</span>]</span>&quot;</span>&gt;</span>
11+
<span class="hljs-tag">&lt;/<span class="hljs-name">DxDataGrid</span>&gt;</span>

test/markup/inline.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ Hello @owner<b>from html</b>
55
Hello @owner
66
from html
77
8-
@@escapedat
8+
@@escapedat
9+
10+
<DxDataGrid T="@WebApiOrder" CustomData="@LoadOrderData("foo")" ShowFilterRow="true" SuperDuper="@Foo["bar"]">
11+
</DxDataGrid>

0 commit comments

Comments
 (0)