-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathjsstacktrace.js
50 lines (49 loc) · 1.33 KB
/
jsstacktrace.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
// @ts-nocheck
jsstacktrace.displayName = 'jsstacktrace'
jsstacktrace.aliases = []
/** @type {import('../core.js').Syntax} */
export default function jsstacktrace(Prism) {
Prism.languages.jsstacktrace = {
'error-message': {
pattern: /^\S.*/m,
alias: 'string'
},
'stack-frame': {
pattern: /(^[ \t]+)at[ \t].*/m,
lookbehind: true,
inside: {
'not-my-code': {
pattern:
/^at[ \t]+(?!\s)(?:node\.js|<unknown>|.*(?:node_modules|\(<anonymous>\)|\(<unknown>|<anonymous>$|\(internal\/|\(node\.js)).*/m,
alias: 'comment'
},
filename: {
pattern: /(\bat\s+(?!\s)|\()(?:[a-zA-Z]:)?[^():]+(?=:)/,
lookbehind: true,
alias: 'url'
},
function: {
pattern:
/(\bat\s+(?:new\s+)?)(?!\s)[_$a-zA-Z\xA0-\uFFFF<][.$\w\xA0-\uFFFF<>]*/,
lookbehind: true,
inside: {
punctuation: /\./
}
},
punctuation: /[()]/,
keyword: /\b(?:at|new)\b/,
alias: {
pattern: /\[(?:as\s+)?(?!\s)[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\]/,
alias: 'variable'
},
'line-number': {
pattern: /:\d+(?::\d+)?\b/,
alias: 'number',
inside: {
punctuation: /:/
}
}
}
}
}
}