-
Notifications
You must be signed in to change notification settings - Fork 0
/
prism-bibtex.js
51 lines (48 loc) · 1.24 KB
/
prism-bibtex.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
(function (Prism) {
var keyword = {
pattern: /\\(?:\ |[^a-z@\s]|[a-z@]+\*?)/i
}
var latex = {
'equation': {
pattern: /(\$\$?)[^\$]+\1/m,
alias: 'function',
inside: keyword
},
'keyword': keyword
};
Prism.languages.bib = {
'comment': /%.*/,
'special': {
pattern: /(^\s*)@(?:preamble|string|comment(?=\s*[({]))/mi,
lookbehind: true,
alias: 'important'
},
'class-name': {
pattern: /(^\s*)@[a-z]+(?=\s*{)/mi,
lookbehind: true
},
'key': {
pattern: /([,{]\s*)[^,={}'"\s]+(?=\s*[,}])/mi,
lookbehind: true,
alias: 'regex'
},
'property': {
pattern: /([,{(]\s*)[^,={}'"\s]+(?=\s*=)/mi,
lookbehind: true
},
'string': {
/* numbers | properly quoted strings | content with braces balanced up to depth 4 */
pattern: /([=#{}]\s*)(?:\d+|("|')(?:(?!\2)[^\\]|\\.)*\2|{(?:(?:{(?:(?:{(?:(?:{(?:[^{}])*})|(?:[^{}]))*})|(?:[^{}]))*})|(?:[^{}]))*})/mi,
lookbehind: true,
greedy: true,
inside: latex
},
'constant': {
pattern: /([=#]\s*)[^,={}'"\s]+(?=\s*[#,}])/mi,
lookbehind: true
},
'symbol': /#/,
'punctuation': /[=,{}()]/
};
Prism.languages.bibtex = Prism.languages.bib;
}(Prism));