-
Notifications
You must be signed in to change notification settings - Fork 0
/
man.sublime-syntax
212 lines (174 loc) · 4.78 KB
/
man.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
%YAML 1.2
---
name: Man (*roff)
scope: text.man
file_extensions: \d
first_line_match: ^([.'])TH\b
variables:
# Requests always have a period (‘.’) or an apostrophe (‘'’)
# as the first character of the input line.
cc: ^([.']) # cc - control character
escape: \\f
macro: (TH|SH|SS|TP|LP|PP|P|IP|HP|RS|RE)\b
numeric: '\b(-)?[0-9.]+\b'
font_size: (SM|SB)\b
font_alt: (BI|IB|RI|IR|BR|RB)\b
font_style: ([BRI])
contexts:
main:
- match: (?={{cc}})
push: macros
- match: (?={{escape}}{{font_style}})
push: font_styles
with_prototype:
- match: '(?={{escape}}|{{cc}})'
meta_content_scope: markup.regular.man
pop: true
# Comments begin and finish at the end of the line
- match: \\["#]
scope: comment.man
push:
- meta_scope: comment.line.man
- match: $
pop: true
macros:
- match: '{{cc}}{{macro}}'
scope: keyword.control.man
push: macros_line
pop: true
- match: '{{cc}}(?={{font_alt}})\b'
scope: keyword.control.man
push: font_alts
with_prototype:
- match: '(?={{escape}}|$)'
pop: true
pop: true
- match: '{{cc}}(?={{font_style}})\b'
scope: keyword.control.man
push: font_styles
with_prototype:
- match: '(?={{escape}}|$)'
pop: true
pop: true
- match: '{{cc}}\w+\b'
scope: support.function.groff
push: macros_line
pop: true
macros_line:
- match: '"'
scope: punctuation.definition.string.begin.man
push:
- meta_scope: string.quoted.double.man
- match: '"'
scope: punctuation.definition.string.end.man
pop: true
- match: '[^\\]\n'
pop: true
- match: '{{numeric}}'
scope: constant.numeric.man
- match: \w
scope: variable.parameter.man
- match: $
pop: true
font_alts:
- match: \bB
scope: keyword.control.man
push: font_alt_bold
- match: \bR
scope: keyword.control.man
push: font_alt_regular
- match: \bI
scope: keyword.control.man
push: font_alt_italic
font_alt_bold:
- match: I\s+
scope: keyword.control.man
push:
- meta_content_scope: markup.bold.man
- include: start_and_end_string
- match: '\s+'
push:
- meta_content_scope: markup.italic.man
- clear_scopes: 1
- include: font_alt_odd_pop
- match: R\s+
scope: keyword.control.man
push:
- meta_content_scope: markup.bold.man
- include: start_and_end_string
- match: '\s+'
push:
- meta_content_scope: markup.regular.man
- clear_scopes: 1
- include: font_alt_odd_pop
font_alt_regular:
- match: B\s+
scope: keyword.control.man
push:
- meta_content_scope: markup.regular.man
- include: start_and_end_string
- match: '\s+'
push:
- meta_content_scope: markup.bold.man
- clear_scopes: 1
- include: font_alt_odd_pop
- match: I\s+
scope: keyword.control.man
push:
- meta_content_scope: markup.regular.man
- include: start_and_end_string
- match: '\s+'
push:
- meta_content_scope: markup.italic.man
- clear_scopes: 1
- include: font_alt_odd_pop
font_alt_italic:
- match: B\s+
scope: keyword.control.man
push:
- meta_content_scope: markup.italic.man
- include: start_and_end_string
- match: '\s+'
push:
- meta_content_scope: markup.bold.man
- clear_scopes: 1
- include: font_alt_odd_pop
- match: R\s+
scope: keyword.control.man
push:
- meta_content_scope: markup.italic.man
- include: start_and_end_string
- match: '\s+'
push:
- meta_content_scope: markup.regular.man
- clear_scopes: 1
- include: font_alt_odd_pop
start_and_end_string:
- match: '(?<=\s)"'
push:
- match: '"[^\s]'
scope: invalid.illegal
pop: true
- match: '"'
pop: true
font_alt_odd_pop:
- include: start_and_end_string
- match: '\s+'
pop: true
font_styles:
- match: (B\b|{{escape}}(B))
captures:
1: keyword.control.man
2: constant.character.escape.man
push:
- meta_content_scope: markup.bold.man
- match: ({{escape}})(R) # only \fR
captures:
1: keyword.control.man
2: constant.character.escape.man
- match: (I\b|{{escape}}(I))
captures:
1: keyword.control.man
2: constant.character.escape.man
push:
- meta_content_scope: markup.italic.man