Skip to content

Commit c4fb1ee

Browse files
committed
0.1.6
1 parent 658f220 commit c4fb1ee

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

dist/ass-compiler.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@
7474
tag.r = text.slice(1);
7575
} else if (/^fs[\d+-]/.test(text)) {
7676
tag.fs = text.slice(2);
77-
} else if (/^\d?c&?H?[0-9a-f]+|^\d?c$/i.test(text)) {
77+
} else if (/^\d?c&?H?[0-9a-fA-F]+|^\d?c$/.test(text)) {
7878
var ref$1 = text.match(/^(\d?)c&?H?(\w*)/);
7979
var num = ref$1[1];
8080
var color = ref$1[2];
8181
tag[("c" + (num || 1))] = color && ("000000" + color).slice(-6);
82-
} else if (/^\da&?H?[0-9a-f]+/i.test(text)) {
82+
} else if (/^\da&?H?[0-9a-fA-F]+/.test(text)) {
8383
var ref$2 = text.match(/^(\d)a&?H?([0-9a-f]+)/i);
8484
var num$1 = ref$2[1];
8585
var alpha = ref$2[2];
8686
tag[("a" + num$1)] = ("00" + alpha).slice(-2);
87-
} else if (/^alpha&?H?[0-9a-f]+/i.test(text)) {
87+
} else if (/^alpha&?H?[0-9a-fA-F]+/.test(text)) {
8888
(assign = text.match(/^alpha&?H?([0-9a-f]+)/i), tag.alpha = assign[1]);
8989
tag.alpha = ("00" + (tag.alpha)).slice(-2);
9090
} else if (/^(?:pos|org|move|fad|fade)\([^)]+/.test(text)) {
@@ -259,6 +259,16 @@
259259
var stylesFormat = ['Name', 'Fontname', 'Fontsize', 'PrimaryColour', 'SecondaryColour', 'OutlineColour', 'BackColour', 'Bold', 'Italic', 'Underline', 'StrikeOut', 'ScaleX', 'ScaleY', 'Spacing', 'Angle', 'BorderStyle', 'Outline', 'Shadow', 'Alignment', 'MarginL', 'MarginR', 'MarginV', 'Encoding'];
260260
var eventsFormat = ['Layer', 'Start', 'End', 'Style', 'Name', 'MarginL', 'MarginR', 'MarginV', 'Effect', 'Text'];
261261

262+
function parseFormat(text) {
263+
var fields = stylesFormat.concat(eventsFormat);
264+
return text.match(/Format\s*:\s*(.*)/i)[1]
265+
.split(/\s*,\s*/)
266+
.map(function (field) {
267+
var caseField = fields.find(function (f) { return f.toLowerCase() === field.toLowerCase(); });
268+
return caseField || field;
269+
});
270+
}
271+
262272
function parseStyle(text, format) {
263273
var values = text.match(/Style\s*:\s*(.*)/i)[1].split(/\s*,\s*/);
264274
return assign.apply(void 0, [ {} ].concat( format.map(function (fmt, idx) {
@@ -296,15 +306,15 @@
296306
}
297307
if (state === 2) {
298308
if (/^Format\s*:/i.test(line)) {
299-
tree.styles.format = stylesFormat.concat();
309+
tree.styles.format = parseFormat(line);
300310
}
301311
if (/^Style\s*:/i.test(line)) {
302312
tree.styles.style.push(parseStyle(line, tree.styles.format));
303313
}
304314
}
305315
if (state === 3) {
306316
if (/^Format\s*:/i.test(line)) {
307-
tree.events.format = eventsFormat.concat();
317+
tree.events.format = parseFormat(line);
308318
}
309319
if (/^(?:Comment|Dialogue)\s*:/i.test(line)) {
310320
var ref$1 = line.match(/^(\w+?)\s*:\s*(.*)/i);
@@ -1064,6 +1074,7 @@
10641074

10651075
function decompileText(dia, style) {
10661076
return dia.slices
1077+
.filter(function (slice) { return slice.fragments.length; })
10671078
.map(function (slice, idx) {
10681079
var sliceCopy = JSON.parse(JSON.stringify(slice));
10691080
var ref = sliceCopy.fragments[0];

0 commit comments

Comments
 (0)