Skip to content

Commit 2420182

Browse files
committed
0.1.15
1 parent d1300f3 commit 2420182

File tree

5 files changed

+39
-23
lines changed

5 files changed

+39
-23
lines changed

dist/ass-compiler.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
}
179179

180180
function parseText(text) {
181-
var pairs = text.split(/{([^{}]*?)}/);
181+
var pairs = text.split(/{(.*?)}/);
182182
var parsed = [];
183183
if (pairs[0].length) {
184184
parsed.push({ tags: [], text: pairs[0], drawing: [] });
@@ -314,7 +314,10 @@
314314
}
315315

316316
function stringifyInfo(info) {
317-
return Object.keys(info).map(function (key) { return (key + ": " + (info[key])); }).join('\n');
317+
return Object.keys(info)
318+
.filter(function (key) { return info[key] !== null; })
319+
.map(function (key) { return (key + ": " + (info[key])); })
320+
.join('\n');
318321
}
319322

320323
function pad00(n) {
@@ -756,9 +759,13 @@
756759
var tag$1 = tags[j$1];
757760
alignment = alignment || a2an[tag$1.a || 0] || tag$1.an;
758761
q = compileTag(tag$1, 'q') || q;
759-
pos = pos || compileTag(tag$1, 'pos');
762+
if (!move) {
763+
pos = pos || compileTag(tag$1, 'pos');
764+
}
760765
org = org || compileTag(tag$1, 'org');
761-
move = move || compileTag(tag$1, 'move');
766+
if (!pos) {
767+
move = move || compileTag(tag$1, 'move');
768+
}
762769
fade = fade || compileTag(tag$1, 'fade') || compileTag(tag$1, 'fad');
763770
clip = compileTag(tag$1, 'clip') || clip;
764771
var key = Object.keys(tag$1)[0];
@@ -965,17 +972,18 @@
965972
if ( options === void 0 ) options = {};
966973

967974
var tree = parse(text);
975+
var info = Object.assign(options.defaultInfo || {}, tree.info);
968976
var styles = compileStyles({
969-
info: tree.info,
977+
info: info,
970978
style: tree.styles.style,
971979
defaultStyle: options.defaultStyle || {},
972980
});
973981
return {
974-
info: tree.info,
975-
width: tree.info.PlayResX * 1 || null,
976-
height: tree.info.PlayResY * 1 || null,
977-
wrapStyle: /^[0-3]$/.test(tree.info.WrapStyle) ? tree.info.WrapStyle * 1 : 2,
978-
collisions: tree.info.Collisions || 'Normal',
982+
info: info,
983+
width: info.PlayResX * 1 || null,
984+
height: info.PlayResY * 1 || null,
985+
wrapStyle: /^[0-3]$/.test(info.WrapStyle) ? info.WrapStyle * 1 : 2,
986+
collisions: info.Collisions || 'Normal',
979987
styles: styles,
980988
dialogues: compileDialogues({
981989
styles: styles,

dist/ass-compiler.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/esm/ass-compiler.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function parseTags(text) {
172172
}
173173

174174
function parseText(text) {
175-
var pairs = text.split(/{([^{}]*?)}/);
175+
var pairs = text.split(/{(.*?)}/);
176176
var parsed = [];
177177
if (pairs[0].length) {
178178
parsed.push({ tags: [], text: pairs[0], drawing: [] });
@@ -308,7 +308,10 @@ function parse(text) {
308308
}
309309

310310
function stringifyInfo(info) {
311-
return Object.keys(info).map(function (key) { return (key + ": " + (info[key])); }).join('\n');
311+
return Object.keys(info)
312+
.filter(function (key) { return info[key] !== null; })
313+
.map(function (key) { return (key + ": " + (info[key])); })
314+
.join('\n');
312315
}
313316

314317
function pad00(n) {
@@ -750,9 +753,13 @@ function compileText(ref) {
750753
var tag$1 = tags[j$1];
751754
alignment = alignment || a2an[tag$1.a || 0] || tag$1.an;
752755
q = compileTag(tag$1, 'q') || q;
753-
pos = pos || compileTag(tag$1, 'pos');
756+
if (!move) {
757+
pos = pos || compileTag(tag$1, 'pos');
758+
}
754759
org = org || compileTag(tag$1, 'org');
755-
move = move || compileTag(tag$1, 'move');
760+
if (!pos) {
761+
move = move || compileTag(tag$1, 'move');
762+
}
756763
fade = fade || compileTag(tag$1, 'fade') || compileTag(tag$1, 'fad');
757764
clip = compileTag(tag$1, 'clip') || clip;
758765
var key = Object.keys(tag$1)[0];
@@ -959,17 +966,18 @@ function compile(text, options) {
959966
if ( options === void 0 ) options = {};
960967

961968
var tree = parse(text);
969+
var info = Object.assign(options.defaultInfo || {}, tree.info);
962970
var styles = compileStyles({
963-
info: tree.info,
971+
info: info,
964972
style: tree.styles.style,
965973
defaultStyle: options.defaultStyle || {},
966974
});
967975
return {
968-
info: tree.info,
969-
width: tree.info.PlayResX * 1 || null,
970-
height: tree.info.PlayResY * 1 || null,
971-
wrapStyle: /^[0-3]$/.test(tree.info.WrapStyle) ? tree.info.WrapStyle * 1 : 2,
972-
collisions: tree.info.Collisions || 'Normal',
976+
info: info,
977+
width: info.PlayResX * 1 || null,
978+
height: info.PlayResY * 1 || null,
979+
wrapStyle: /^[0-3]$/.test(info.WrapStyle) ? info.WrapStyle * 1 : 2,
980+
collisions: info.Collisions || 'Normal',
973981
styles: styles,
974982
dialogues: compileDialogues({
975983
styles: styles,

0 commit comments

Comments
 (0)