-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
javadoc.js
105 lines (104 loc) · 3.12 KB
/
javadoc.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// @ts-nocheck
import refractorJava from './java.js'
import refractorJavadoclike from './javadoclike.js'
import refractorMarkup from './markup.js'
javadoc.displayName = 'javadoc'
javadoc.aliases = []
/** @type {import('../core.js').Syntax} */
export default function javadoc(Prism) {
Prism.register(refractorJava)
Prism.register(refractorJavadoclike)
Prism.register(refractorMarkup)
;(function (Prism) {
var codeLinePattern = /(^(?:[\t ]*(?:\*\s*)*))[^*\s].*$/m
var memberReference = /#\s*\w+(?:\s*\([^()]*\))?/.source
var reference =
/(?:\b[a-zA-Z]\w+\s*\.\s*)*\b[A-Z]\w*(?:\s*<mem>)?|<mem>/.source.replace(
/<mem>/g,
function () {
return memberReference
}
)
Prism.languages.javadoc = Prism.languages.extend('javadoclike', {})
Prism.languages.insertBefore('javadoc', 'keyword', {
reference: {
pattern: RegExp(
/(@(?:exception|link|linkplain|see|throws|value)\s+(?:\*\s*)?)/
.source +
'(?:' +
reference +
')'
),
lookbehind: true,
inside: {
function: {
pattern: /(#\s*)\w+(?=\s*\()/,
lookbehind: true
},
field: {
pattern: /(#\s*)\w+/,
lookbehind: true
},
namespace: {
pattern: /\b(?:[a-z]\w*\s*\.\s*)+/,
inside: {
punctuation: /\./
}
},
'class-name': /\b[A-Z]\w*/,
keyword: Prism.languages.java.keyword,
punctuation: /[#()[\],.]/
}
},
'class-name': {
// @param <T> the first generic type parameter
pattern: /(@param\s+)<[A-Z]\w*>/,
lookbehind: true,
inside: {
punctuation: /[.<>]/
}
},
'code-section': [
{
pattern:
/(\{@code\s+(?!\s))(?:[^\s{}]|\s+(?![\s}])|\{(?:[^{}]|\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\})*\})+(?=\s*\})/,
lookbehind: true,
inside: {
code: {
// there can't be any HTML inside of {@code} tags
pattern: codeLinePattern,
lookbehind: true,
inside: Prism.languages.java,
alias: 'language-java'
}
}
},
{
pattern:
/(<(code|pre|tt)>(?!<code>)\s*)\S(?:\S|\s+\S)*?(?=\s*<\/\2>)/,
lookbehind: true,
inside: {
line: {
pattern: codeLinePattern,
lookbehind: true,
inside: {
// highlight HTML tags and entities
tag: Prism.languages.markup.tag,
entity: Prism.languages.markup.entity,
code: {
// everything else is Java code
pattern: /.+/,
inside: Prism.languages.java,
alias: 'language-java'
}
}
}
}
}
],
tag: Prism.languages.markup.tag,
entity: Prism.languages.markup.entity
})
Prism.languages.javadoclike.addSupport('java', Prism.languages.javadoc)
})(Prism)
}