-
Notifications
You must be signed in to change notification settings - Fork 2
/
Bibtex.sublime-syntax
131 lines (130 loc) · 4.14 KB
/
Bibtex.sublime-syntax
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
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: BibTeX
comment: |
Grammar based on description from http://artis.imag.fr/~Xavier.Decoret/resources/xdkbibtex/bibtex_summary.html#comment
TODO: Does not support @preamble
file_extensions:
- bib
scope: text.bibtex
contexts:
main:
- match: "@Comment"
captures:
0: punctuation.definition.comment.bibtex
push:
- meta_scope: comment.line.at-sign.bibtex
- match: $\n?
pop: true
- match: '((@)String)\s*(\{)\s*([a-zA-Z]*)'
captures:
1: keyword.other.string-constant.bibtex
2: punctuation.definition.keyword.bibtex
3: punctuation.section.string-constant.begin.bibtex
4: variable.other.bibtex
push:
- meta_scope: meta.string-constant.braces.bibtex
- match: '\}'
captures:
0: punctuation.section.string-constant.end.bibtex
pop: true
- include: string_content
- match: '((@)String)\s*(\()\s*([a-zA-Z]*)'
captures:
1: keyword.other.string-constant.bibtex
2: punctuation.definition.keyword.bibtex
3: punctuation.section.string-constant.begin.bibtex
4: variable.other.bibtex
push:
- meta_scope: meta.string-constant.parenthesis.bibtex
- match: \)
captures:
0: punctuation.section.string-constant.end.bibtex
pop: true
- include: string_content
- match: '((@)[a-zA-Z]+)\s*(\{)\s*([^\s,]*)'
captures:
1: keyword.other.entry-type.bibtex
2: punctuation.definition.keyword.bibtex
3: punctuation.section.entry.begin.bibtex
4: entity.name.type.entry-key.bibtex
push:
- meta_scope: meta.entry.braces.bibtex
- match: '\}'
captures:
0: punctuation.section.entry.end.bibtex
pop: true
- match: '([a-zA-Z0-9\!\$\&\*\+\-\.\/\:\;\<\>\?\[\]\^\_\`\|]+)\s*(\=)'
captures:
1: string.unquoted.key.bibtex
2: punctuation.separator.key-value.bibtex
push:
- meta_scope: meta.key-assignment.bibtex
- match: "(?=[,}])"
pop: true
- include: string_content
- include: integer
- match: '((@)[a-zA-Z]+)\s*(\()\s*([^\s,]*)'
captures:
1: keyword.other.entry-type.bibtex
2: punctuation.definition.keyword.bibtex
3: punctuation.section.entry.begin.bibtex
4: entity.name.type.entry-key.bibtex
push:
- meta_scope: meta.entry.parenthesis.bibtex
- match: \)
captures:
0: punctuation.section.entry.end.bibtex
pop: true
- match: '([a-zA-Z0-9\!\$\&\*\+\-\.\/\:\;\<\>\?\[\]\^\_\`\|]+)\s*(\=)'
captures:
1: string.unquoted.key.bibtex
2: punctuation.separator.key-value.bibtex
push:
- meta_scope: meta.key-assignment.bibtex
- match: "(?=[,)])"
pop: true
- include: string_content
- include: integer
- match: '[^@\n]'
push:
- meta_scope: comment.block.bibtex
- match: (?=@)
pop: true
integer:
- match: \d+
scope: constant.numeric.bibtex
nested_braces:
- match: '\{'
captures:
0: punctuation.definition.group.begin.bibtex
push:
- match: '\}'
captures:
0: punctuation.definition.group.end.bibtex
pop: true
- include: nested_braces
string_content:
- match: '"'
captures:
0: punctuation.definition.string.begin.bibtex
push:
- meta_scope: string.quoted.double.bibtex
- match: '"'
captures:
0: punctuation.definition.string.end.bibtex
pop: true
- include: nested_braces
- match: '\{'
captures:
0: punctuation.definition.string.begin.bibtex
push:
- meta_scope: string.quoted.other.braces.bibtex
- match: '\}'
captures:
0: punctuation.definition.string.end.bibtex
pop: true
- match: "@"
scope: invalid.illegal.at-sign.bibtex
- include: nested_braces