Skip to content

Commit d111cfc

Browse files
aspnet
1 parent c514b20 commit d111cfc

File tree

1 file changed

+32
-37
lines changed

1 file changed

+32
-37
lines changed

src/languages/aspnet.js

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { insertBefore } from '../util/language-util.js';
21
import csharp from './csharp.js';
32
import markup from './markup.js';
43

@@ -16,42 +15,11 @@ export default {
1615
pattern: /<%\s*?[$=%#:]{0,2}|%>/,
1716
alias: 'tag',
1817
},
19-
$rest: /** @type {Grammar['$rest']} */ ('csharp'),
18+
$rest: 'csharp',
2019
},
2120
});
2221

23-
const tag =
24-
/** @type {GrammarToken & { inside: { 'attr-value': { inside: Grammar } } }} */ (
25-
base['tag']
26-
);
27-
28-
// Regexp copied from markup, with a negative look-ahead added
29-
tag.pattern =
30-
/<(?!%)\/?[^\s>\/]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/;
31-
32-
// match directives of attribute value foo="<% Bar %>"
33-
insertBefore(tag.inside['attr-value'].inside, 'punctuation', {
34-
'directive': directive,
35-
});
36-
37-
insertBefore(base, 'comment', {
38-
'asp-comment': {
39-
pattern: /<%--[\s\S]*?--%>/,
40-
alias: ['asp', 'comment'],
41-
},
42-
});
43-
44-
// script runat="server" contains csharp, not javascript
45-
insertBefore(base, 'script' in base ? 'script' : 'tag', {
46-
'asp-script': {
47-
pattern: /(<script(?=.*runat=['"]?server\b)[^>]*>)[\s\S]*?(?=<\/script>)/i,
48-
lookbehind: true,
49-
alias: ['asp', 'script'],
50-
inside: 'csharp',
51-
},
52-
});
53-
54-
return /** @type {Grammar} */ ({
22+
return {
5523
'page-directive': {
5624
pattern: /<%\s*@.*%>/,
5725
alias: 'tag',
@@ -61,15 +29,42 @@ export default {
6129
/<%\s*@\s*(?:Assembly|Control|Implements|Import|Master(?:Type)?|OutputCache|Page|PreviousPageType|Reference|Register)?|%>/i,
6230
alias: 'tag',
6331
},
64-
$rest: /** @type {Grammar['$rest']} */ (tag.inside),
32+
$rest: /** @type {GrammarToken} */ (base['tag']).inside,
6533
},
6634
},
6735
'directive': directive,
68-
});
36+
$merge: {
37+
'tag': {
38+
// Regexp copied from markup, with a negative look-ahead added
39+
pattern:
40+
/<(?!%)\/?[^\s>\/]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/,
41+
},
42+
},
43+
$insertBefore: {
44+
'tag/attr-value/punctuation': {
45+
// match directives of attribute value foo="<% Bar %>"
46+
'directive': directive,
47+
},
48+
'comment': {
49+
'asp-comment': {
50+
pattern: /<%--[\s\S]*?--%>/,
51+
alias: ['asp', 'comment'],
52+
},
53+
},
54+
// script runat="server" contains csharp, not javascript
55+
['script' in base ? 'script' : 'tag']: {
56+
'asp-script': {
57+
pattern: /(<script(?=.*runat=['"]?server\b)[^>]*>)[\s\S]*?(?=<\/script>)/i,
58+
lookbehind: true,
59+
alias: ['asp', 'script'],
60+
inside: 'csharp',
61+
},
62+
},
63+
},
64+
};
6965
},
7066
};
7167

7268
/**
73-
* @typedef {import('../types.d.ts').Grammar} Grammar
7469
* @typedef {import('../types.d.ts').GrammarToken} GrammarToken
7570
*/

0 commit comments

Comments
 (0)