diff --git a/package.json b/package.json index 7e3a213..ff54891 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vestaboard/vbml", - "version": "1.2.2", + "version": "1.2.3", "description": "The Vestaboard markup language", "main": "lib/index.js", "scripts": { diff --git a/src/__tests__/classic.spec.ts b/src/__tests__/classic.spec.ts index 7d009b3..ddbc94e 100644 --- a/src/__tests__/classic.spec.ts +++ b/src/__tests__/classic.spec.ts @@ -43,8 +43,6 @@ describe("Classic", () => { }); it("Should convert string to classic board", () => { - // should be 3 lines - // 57 characters const string = "reallylongwordthatismorethantwentytwocharcters"; const classicBoard = classic(string); expect(classicBoard).toEqual([ @@ -64,8 +62,6 @@ describe("Classic", () => { }); it("Should convert string to classic board", () => { - // should be 3 lines - // 57 characters const string = "reallylongwordthatismorethan22charcters"; const classicBoard = classic(string); expect(classicBoard).toEqual([ @@ -85,8 +81,6 @@ describe("Classic", () => { }); it("Should convert string to classic board", () => { - // should be 3 lines - // 57 characters const string = `hello world`; const classicBoard = classic(string); @@ -101,15 +95,11 @@ describe("Classic", () => { }); it("Should convert string to classic board", () => { - // should be 3 lines - // 57 characters const string = `hello\n\nworld`; const classicBoard = classic(string); expect(classicBoard).toEqual([[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,8,5,12,12,15,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,23,15,18,12,4,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]); }); it("Should convert string to classic board", () => { - // should be 3 lines - // 57 characters const string = ``; const classicBoard = classic(string); const emptyRow = new Array(22).fill(0); @@ -123,4 +113,47 @@ describe("Classic", () => { emptyRow, ]); }); + + it("Should convert string to classic board", () => { + const string = `{1}`; + const classicBoard = classic(string); + expect(classicBoard).toEqual( [ + [ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0 + ] + ]); + }); }); diff --git a/src/classic.ts b/src/classic.ts index 7063016..ded8018 100644 --- a/src/classic.ts +++ b/src/classic.ts @@ -261,13 +261,13 @@ export function classic(text: string, extraHPadding = 0): Array> { } const lines = text.split("\n"); - const wordCharCodeRegex = /[a-zA-Z]+|\{.\d\}+|\d+|\s+|[^\w\s]/g; + const wordCharCodeRegex = /[a-zA-Z]+|\{.\d\}+|\{\d\}+|\d+|\s+|[^\w\s]/g; const chunkedLines = lines.map((line) => { const words = line.match(wordCharCodeRegex); return words; }); - + const vestaboardCharsLines = chunkedLines .map((line) => { return line?.flatMap((word) => {