Compare commits

..

No commits in common. "d1d88cc09e00253dfe519830cfa657dece8b9093" and "2d1833b56662fd6c6f9e8db1f2c587e205a97b3e" have entirely different histories.

3 changed files with 19 additions and 10 deletions

View File

@ -956,7 +956,8 @@ class Range extends ContentObject {
[$finalize]() { [$finalize]() {
this[$content] = this[$content] this[$content] = this[$content]
.split(",", 2) .trim()
.split(/\s*,\s*/, 2)
.map(range => range.split("-").map(x => parseInt(x.trim(), 10))) .map(range => range.split("-").map(x => parseInt(x.trim(), 10)))
.filter(range => range.every(x => !isNaN(x))) .filter(range => range.every(x => !isNaN(x)))
.map(range => { .map(range => {
@ -1307,7 +1308,10 @@ class Window extends ContentObject {
} }
[$finalize]() { [$finalize]() {
const pair = this[$content].split(",", 2).map(x => parseInt(x.trim(), 10)); const pair = this[$content]
.trim()
.split(/\s*,\s*/, 2)
.map(x => parseInt(x, 10));
if (pair.some(x => isNaN(x))) { if (pair.some(x => isNaN(x))) {
this[$content] = [0, 0]; this[$content] = [0, 0];
return; return;

View File

@ -106,8 +106,9 @@ function getRatio(data) {
return { num: 1, den: 1 }; return { num: 1, den: 1 };
} }
const ratio = data const ratio = data
.split(":", 2) .trim()
.map(x => parseFloat(x.trim())) .split(/\s*:\s*/)
.map(x => parseFloat(x))
.filter(x => !isNaN(x)); .filter(x => !isNaN(x));
if (ratio.length === 1) { if (ratio.length === 1) {
ratio.push(1); ratio.push(1);
@ -140,7 +141,8 @@ function getColor(data, def = [0, 0, 0]) {
return { r, g, b }; return { r, g, b };
} }
const color = data const color = data
.split(",", 3) .trim()
.split(/\s*,\s*/)
.map(c => MathClamp(parseInt(c.trim(), 10), 0, 255)) .map(c => MathClamp(parseInt(c.trim(), 10), 0, 255))
.map(c => (isNaN(c) ? 0 : c)); .map(c => (isNaN(c) ? 0 : c));
@ -157,8 +159,10 @@ function getBBox(data) {
if (!data) { if (!data) {
return { x: def, y: def, width: def, height: def }; return { x: def, y: def, width: def, height: def };
} }
const bbox = data.split(",", 4).map(m => getMeasurement(m.trim(), "-1")); const bbox = data
.trim()
.split(/\s*,\s*/)
.map(m => getMeasurement(m, "-1"));
if (bbox.length < 4 || bbox[2] < 0 || bbox[3] < 0) { if (bbox.length < 4 || bbox[2] < 0 || bbox[3] < 0) {
return { x: def, y: def, width: def, height: def }; return { x: def, y: def, width: def, height: def };
} }

View File

@ -191,9 +191,10 @@ function checkStyle(node) {
// Remove any non-allowed keys. // Remove any non-allowed keys.
return node.style return node.style
.split(";") .trim()
.filter(s => !!s.trim()) .split(/\s*;\s*/)
.map(s => s.split(":", 2).map(t => t.trim())) .filter(s => !!s)
.map(s => s.split(/\s*:\s*/, 2))
.filter(([key, value]) => { .filter(([key, value]) => {
if (key === "font-family") { if (key === "font-family") {
node[$globalData].usedTypefaces.add(value); node[$globalData].usedTypefaces.add(value);