diff --git a/src/chord_sheet/paragraph.ts b/src/chord_sheet/paragraph.ts index fec880fd..0d9e9e11 100644 --- a/src/chord_sheet/paragraph.ts +++ b/src/chord_sheet/paragraph.ts @@ -26,19 +26,23 @@ class Paragraph { * @returns {boolean} */ isLiteral() { - return this - .lines - .every((line) => line.items.every((item) => { - if (item instanceof Literal) { - return true; - } + const { lines } = this; + + if (lines.length === 0) { + return false; + } + + return lines.every((line) => line.items.every((item) => { + if (item instanceof Literal) { + return true; + } - if (item instanceof Tag && (item as Tag).isSectionDelimiter()) { - return true; - } + if (item instanceof Tag && (item as Tag).isSectionDelimiter()) { + return true; + } - return false; - })); + return false; + })); } /** diff --git a/test/chord_sheet/paragraph.test.ts b/test/chord_sheet/paragraph.test.ts index 64979f9c..382d0a89 100644 --- a/test/chord_sheet/paragraph.test.ts +++ b/test/chord_sheet/paragraph.test.ts @@ -70,6 +70,14 @@ describe('Paragraph', () => { expect(paragraph.isLiteral()).toBe(false); }); }); + + describe('when the paragraph is empty', () => { + it('returns false', () => { + const paragraph = createParagraph([]); + + expect(paragraph.isLiteral()).toBe(false); + }); + }); }); describe('#contents', () => { diff --git a/test/formatter/html_table_formatter.test.ts b/test/formatter/html_table_formatter.test.ts index 06cdd4dd..396f21f4 100644 --- a/test/formatter/html_table_formatter.test.ts +++ b/test/formatter/html_table_formatter.test.ts @@ -654,6 +654,34 @@ describe('HtmlTableFormatter', () => { expect(new HtmlTableFormatter({ key: 'Eb' }).format(exampleSongSymbol)).toEqual(expectedChordSheet); }); + it('correctly renders blank lines', () => { + const song = createSongFromAst([ + [chordLyricsPair('C', 'Whisper words of wisdom')], + [], + [], + ]); + + const expectedOutput = html` +
+
+ + + + + + + +
C
Whisper words of wisdom
+
+
+
+
+ `; + + const output = new HtmlTableFormatter().format(song); + expect(output).toEqual(expectedOutput); + }); + describe('with option useUnicodeModifiers:true', () => { it('replaces # with unicode sharp', () => { const songWithSharps = createSongFromAst([