-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
aspnet.js
70 lines (67 loc) · 1.93 KB
/
aspnet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// @ts-nocheck
import refractorCsharp from './csharp.js'
import refractorMarkup from './markup.js'
aspnet.displayName = 'aspnet'
aspnet.aliases = []
/** @type {import('../core.js').Syntax} */
export default function aspnet(Prism) {
Prism.register(refractorCsharp)
Prism.register(refractorMarkup)
Prism.languages.aspnet = Prism.languages.extend('markup', {
'page-directive': {
pattern: /<%\s*@.*%>/,
alias: 'tag',
inside: {
'page-directive': {
pattern:
/<%\s*@\s*(?:Assembly|Control|Implements|Import|Master(?:Type)?|OutputCache|Page|PreviousPageType|Reference|Register)?|%>/i,
alias: 'tag'
},
rest: Prism.languages.markup.tag.inside
}
},
directive: {
pattern: /<%.*%>/,
alias: 'tag',
inside: {
directive: {
pattern: /<%\s*?[$=%#:]{0,2}|%>/,
alias: 'tag'
},
rest: Prism.languages.csharp
}
}
})
// Regexp copied from prism-markup, with a negative look-ahead added
Prism.languages.aspnet.tag.pattern =
/<(?!%)\/?[^\s>\/]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/
// match directives of attribute value foo="<% Bar %>"
Prism.languages.insertBefore(
'inside',
'punctuation',
{
directive: Prism.languages.aspnet['directive']
},
Prism.languages.aspnet.tag.inside['attr-value']
)
Prism.languages.insertBefore('aspnet', 'comment', {
'asp-comment': {
pattern: /<%--[\s\S]*?--%>/,
alias: ['asp', 'comment']
}
})
// script runat="server" contains csharp, not javascript
Prism.languages.insertBefore(
'aspnet',
Prism.languages.javascript ? 'script' : 'tag',
{
'asp-script': {
pattern:
/(<script(?=.*runat=['"]?server\b)[^>]*>)[\s\S]*?(?=<\/script>)/i,
lookbehind: true,
alias: ['asp', 'script'],
inside: Prism.languages.csharp || {}
}
}
)
}