diff --git a/src/util/gin.ts b/src/util/gin.ts index 0b9d36a..039a9a8 100644 --- a/src/util/gin.ts +++ b/src/util/gin.ts @@ -61,6 +61,10 @@ function _parse(text: string, root: Node): Node { const j = open.pop()!; textNode.endIndex = j; + + if (textNode.startIndex! > 0 && text.charAt(textNode.startIndex!) == '\n') { + textNode.startIndex!++; + } textNode.text = text.substring(textNode.startIndex!, textNode.endIndex!) switch (scope.type) { diff --git a/test/util/gin.test.ts b/test/util/gin.test.ts index cadd526..9941bf1 100644 --- a/test/util/gin.test.ts +++ b/test/util/gin.test.ts @@ -41,7 +41,6 @@ Josie`; const expected = `Dear Aunt Mildred, - It was a pleasure to see you at the wedding. Thank you for the lovely bone china tea set. @@ -49,7 +48,6 @@ Best wishes, Josie Dear Uncle John, - It is a shame you couldn't make it to the wedding. Thank you for the lovely moleskin pants. @@ -57,15 +55,15 @@ Best wishes, Josie Dear Cousin Rodney, - It is a shame you couldn't make it to the wedding. Best wishes, Josie` - const actual = data.map(r => Gin.execute(template, r)).join('\n'); - console.log(actual) + const actual = data.map(r => Gin.execute(template, r)).join('\n\n'); + console.debug(Gin.execute(template, data[0])) expect(actual).toEqual(expected); + }) // it('parseGlob', async () => {