small tweaks

This commit is contained in:
Dylan Pizzo
2025-01-06 22:28:57 -05:00
parent 28f214fb51
commit 9cef34b976
4 changed files with 37 additions and 6 deletions

View File

@@ -233,6 +233,9 @@ export const measureDominionText = async (
) {
line.pieces = line.pieces.slice(0, -1);
}
line.width = line.pieces
.map((piece) => piece.measure.width)
.reduce((a, b) => a + b);
return line;
}),
width: Math.max(...lines.map((line) => line.width)),
@@ -308,7 +311,7 @@ export const parse = (text: string): Piece[] => {
pieces.push({ type: "coin", text: text.slice(i + 1, i + end) });
i += end - 1;
} else {
const end = text.slice(i).match(/\S+/)![0].length;
const end = text.slice(i).match(/[^$ \n]+/)![0].length;
pieces.push({ type: "text", text: text.slice(i, i + end) });
i += end - 1;
}