-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
text.bibtex.js
143 lines (141 loc) · 4.73 KB
/
text.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/textmate/latex.tmbundle>
// and licensed permissive.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.bib', '.bibtex'],
names: ['bibtex'],
patterns: [
{
begin: '@Comment',
beginCaptures: {0: {name: 'punctuation.definition.comment.bibtex'}},
end: '$\\n?',
name: 'comment.line.at-sign.bibtex'
},
{
begin: '((@)String)\\s*(\\{)\\s*([a-zA-Z]*)',
beginCaptures: {
1: {name: 'keyword.other.string-constant.bibtex'},
2: {name: 'punctuation.definition.keyword.bibtex'},
3: {name: 'punctuation.section.string-constant.begin.bibtex'},
4: {name: 'variable.other.bibtex'}
},
end: '\\}',
endCaptures: {
0: {name: 'punctuation.section.string-constant.end.bibtex'}
},
name: 'meta.string-constant.braces.bibtex',
patterns: [{include: '#string_content'}]
},
{
begin: '((@)String)\\s*(\\()\\s*([a-zA-Z]*)',
beginCaptures: {
1: {name: 'keyword.other.string-constant.bibtex'},
2: {name: 'punctuation.definition.keyword.bibtex'},
3: {name: 'punctuation.section.string-constant.begin.bibtex'},
4: {name: 'variable.other.bibtex'}
},
end: '\\)',
endCaptures: {
0: {name: 'punctuation.section.string-constant.end.bibtex'}
},
name: 'meta.string-constant.parenthesis.bibtex',
patterns: [{include: '#string_content'}]
},
{
begin: '((@)[a-zA-Z]+)\\s*(\\{)\\s*([^\\s,]*)',
beginCaptures: {
1: {name: 'keyword.other.entry-type.bibtex'},
2: {name: 'punctuation.definition.keyword.bibtex'},
3: {name: 'punctuation.section.entry.begin.bibtex'},
4: {name: 'entity.name.type.entry-key.bibtex'}
},
end: '\\}',
endCaptures: {0: {name: 'punctuation.section.entry.end.bibtex'}},
name: 'meta.entry.braces.bibtex',
patterns: [
{
begin:
'([a-zA-Z0-9\\!\\$\\&\\*\\+\\-\\.\\/\\:\\;\\<\\>\\?\\[\\]\\^\\_\\`\\|]+)\\s*(\\=)',
beginCaptures: {
1: {name: 'string.unquoted.key.bibtex'},
2: {name: 'punctuation.separator.key-value.bibtex'}
},
end: '(?=[,}])',
name: 'meta.key-assignment.bibtex',
patterns: [{include: '#string_content'}, {include: '#integer'}]
}
]
},
{
begin: '((@)[a-zA-Z]+)\\s*(\\()\\s*([^\\s,]*)',
beginCaptures: {
1: {name: 'keyword.other.entry-type.bibtex'},
2: {name: 'punctuation.definition.keyword.bibtex'},
3: {name: 'punctuation.section.entry.begin.bibtex'},
4: {name: 'entity.name.type.entry-key.bibtex'}
},
end: '\\)',
endCaptures: {0: {name: 'punctuation.section.entry.end.bibtex'}},
name: 'meta.entry.parenthesis.bibtex',
patterns: [
{
begin:
'([a-zA-Z0-9\\!\\$\\&\\*\\+\\-\\.\\/\\:\\;\\<\\>\\?\\[\\]\\^\\_\\`\\|]+)\\s*(\\=)',
beginCaptures: {
1: {name: 'string.unquoted.key.bibtex'},
2: {name: 'punctuation.separator.key-value.bibtex'}
},
end: '(?=[,)])',
name: 'meta.key-assignment.bibtex',
patterns: [{include: '#string_content'}, {include: '#integer'}]
}
]
},
{begin: '[^@\\n]', end: '(?=@)', name: 'comment.block.bibtex'}
],
repository: {
integer: {match: '\\d+', name: 'constant.numeric.bibtex'},
nested_braces: {
begin: '\\{',
beginCaptures: {0: {name: 'punctuation.definition.group.begin.bibtex'}},
end: '\\}',
endCaptures: {0: {name: 'punctuation.definition.group.end.bibtex'}},
patterns: [{include: '#nested_braces'}]
},
string_content: {
patterns: [
{
begin: '"',
beginCaptures: {
0: {name: 'punctuation.definition.string.begin.bibtex'}
},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.bibtex'}},
name: 'string.quoted.double.bibtex',
patterns: [{include: '#nested_braces'}]
},
{
begin: '\\{',
beginCaptures: {
0: {name: 'punctuation.definition.string.begin.bibtex'}
},
end: '\\}',
endCaptures: {0: {name: 'punctuation.definition.string.end.bibtex'}},
name: 'string.quoted.other.braces.bibtex',
patterns: [
{match: '@', name: 'invalid.illegal.at-sign.bibtex'},
{include: '#nested_braces'}
]
}
]
}
},
scopeName: 'text.bibtex'
}
export default grammar