Skip to content

Commit 07b9cf7

Browse files
committed
Improve captions italic and bold tag regex
1 parent 5e5e85c commit 07b9cf7

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed

samples/resource/subtitles_english.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ lang
66
"character.00" "<clr:255,125,240>Oh hi!"
77
"character.01" "<clr:255,125,240>What do you mean you still write captions in notepad?"
88
"character.02" "<clr:255,125,240>You know, I used to do the same, but ever since I found this vscode extension, I could never live without it."
9-
"character.03" "<clr:255,125,240>It's just great, <I>I'm telling you!"
9+
"character.03" "<clr:255,125,240>It's just great, <I>I'm telling you!<I>"
1010
"character.04" "<clr:255,125,240>It doesn't just color in basic keywords, no it actually formats markup."
1111
"character.05" "<clr:255,125,240>With this plugin, formatting tags like <B>bold<B> or <I>italic<I> actually receive their styles."
1212
"character.06" "<clr:55,250,240>But it doesn't end there. In fact, the color value of the clr tag shows you a preview of what this color looks like!<delay:5.0> Isn't that <clr:115,225,240>awesome?"

syntaxes/captions.tmLanguage.json

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"repository": {
1717
"langName": {
1818
"match": "^\"?(?i)lang(?-i)\"?",
19-
"name": "entity.name.class.fgd"
19+
"name": "entity.name.class.captions"
2020
},
2121
"langBody": {
2222
"begin": "{",
@@ -43,7 +43,7 @@
4343
"data": {
4444
"begin": "{",
4545
"end": "}",
46-
"contentName": "meta.captions.body.fgd",
46+
"contentName": "meta.captions.body.captions",
4747
"patterns": [
4848
{
4949
"include": "#captionLine"
@@ -57,7 +57,7 @@
5757
"begin": "(\"?[\\w.+#\\\\/-]+\"?)",
5858
"beginCaptures": {
5959
"1": {
60-
"name": "variable.name.fgd"
60+
"name": "variable.name.captions"
6161
}
6262
},
6363
"end": "\n",
@@ -70,7 +70,7 @@
7070
"name": "string.quoted.double"
7171
}
7272
},
73-
"contentName": "string.caption.fgd",
73+
"contentName": "string.caption.captions",
7474
"patterns": [
7575
{
7676
"include": "#tagItalic"
@@ -95,78 +95,84 @@
9595
]
9696
},
9797
"tagItalic": {
98-
"match": "(<[iI]>)([\\w '..,!?&\\[\\]\\(\\)]+)(<[iI]>)?",
99-
"captures": {
100-
"1": { "name": "storage.modifier.fgd" },
101-
"3": { "name": "storage.modifier.fgd" }
98+
"begin": "<[iI]>",
99+
"end": "<[iI]>",
100+
"beginCaptures": {
101+
"0": { "name": "storage.modifier.captions" }
102+
},
103+
"endCaptures": {
104+
"0": { "name": "storage.modifier.captions" }
102105
},
103-
"name": "markup.italic.fgd"
106+
"contentName": "markup.italic.captions"
104107
},
105108
"tagBold": {
106-
"match": "(<[bB]>)([\\w '..,!?&\\[\\]\\(\\)]+)(<[bB]>)?",
107-
"captures": {
108-
"1": { "name": "storage.modifier.fgd" },
109-
"3": { "name": "storage.modifier.fgd" }
109+
"begin": "<[bB]>",
110+
"end": "<[bB]>",
111+
"beginCaptures": {
112+
"0": { "name": "storage.modifier.captions" }
113+
},
114+
"endCaptures": {
115+
"0": { "name": "storage.modifier.captions" }
110116
},
111-
"name": "markup.bold.fgd"
117+
"contentName": "markup.bold.captions"
112118
},
113119
"tagSfx": {
114120
"match": "\\<(?i)sfx(?-i)\\>",
115121
"captures": {
116-
"0": { "name": "storage.modifier.fgd" }
122+
"0": { "name": "storage.modifier.captions" }
117123
}
118124
},
119125
"tagDelayLenNorepeat": {
120126
"match": "\\<((?i)(delay|norepeat|len)(?-i))(:)(\\d+(\\.\\d+)?)\\>",
121127
"captures": {
122128
"0": {
123-
"name": "storage.modifier.fgd"
129+
"name": "storage.modifier.captions"
124130
},
125131
"3": {
126-
"name": "constant.numeric.fgd"
132+
"name": "constant.numeric.captions"
127133
}
128134
}
129135
},
130136
"tagClr": {
131137
"match": "\\<((?i)clr(?-i))(:)(\\d{1,3})\\s*(,)(\\d{1,3})\\s*(,)(\\d{1,3})\\>",
132138
"captures": {
133139
"0": {
134-
"name": "storage.modifier.fgd"
140+
"name": "storage.modifier.captions"
135141
},
136142
"3": {
137-
"name": "constant.numeric.fgd"
143+
"name": "constant.numeric.captions"
138144
},
139145
"5": {
140-
"name": "constant.numeric.fgd"
146+
"name": "constant.numeric.captions"
141147
},
142148
"7": {
143-
"name": "constant.numeric.fgd"
149+
"name": "constant.numeric.captions"
144150
}
145151
}
146152
},
147153
"tagPlayerClr": {
148154
"match": "\\<((?i)playerclr(?-i))(:)(\\d{1,3})\\s*(,)(\\d{1,3})\\s*(,)(\\d{1,3})(:)(\\d{1,3})\\s*(,)(\\d{1,3})\\s*(,)(\\d{1,3})\\>",
149155
"captures": {
150156
"0": {
151-
"name": "storage.modifier.fgd"
157+
"name": "storage.modifier.captions"
152158
},
153159
"3": {
154-
"name": "constant.numeric.fgd"
160+
"name": "constant.numeric.captions"
155161
},
156162
"5": {
157-
"name": "constant.numeric.fgd"
163+
"name": "constant.numeric.captions"
158164
},
159165
"7": {
160-
"name": "constant.numeric.fgd"
166+
"name": "constant.numeric.captions"
161167
},
162168
"9": {
163-
"name": "constant.numeric.fgd"
169+
"name": "constant.numeric.captions"
164170
},
165171
"11": {
166-
"name": "constant.numeric.fgd"
172+
"name": "constant.numeric.captions"
167173
},
168174
"13": {
169-
"name": "constant.numeric.fgd"
175+
"name": "constant.numeric.captions"
170176
}
171177
}
172178
}

0 commit comments

Comments
 (0)