Parser: blank lines should split implicit verses into separate sections #29

Closed
opened 2026-03-17 15:29:18 +01:00 by shahondin1624 · 0 comments

Description

The ChordPro parser (ChordProParser.kt, line 76) skips blank lines with if (line.isBlank()) continue. This means that songs which use blank lines to separate stanzas (without explicit {start_of_verse}/{end_of_verse} directives) are parsed as a single section containing all lyrics.

This is the standard way stanzas are separated in ChordPro files, and the actual song files in the project confirm this pattern — e.g. am-brunnen-vor-dem-tore.chopro has three stanzas separated by blank lines, but no section directives.

As a result, verseSpacing (the gap between sections) is never applied between stanzas, making the rendered output appear as one continuous block of text.

Root Cause

ChordProParser.kt:76:

if (line.isBlank()) continue

When inside an implicit verse (no explicit {start_of_verse} was used, but currentType was set to VERSE at line 162-163), a blank line should flush the current section and allow the next non-blank line to start a new implicit verse.

Acceptance Criteria

  • When the parser encounters a blank line while inside an implicit verse section (started without an explicit {start_of_verse} directive), it flushes the current section
  • The next non-blank lyric line starts a new implicit VERSE section
  • Songs with explicit {start_of_verse}/{end_of_verse} directives still work correctly (blank lines within explicit sections should be ignored, as the section boundary is explicit)
  • Blank lines between metadata directives (before any lyrics) do not create empty sections
  • Existing tests pass, new tests cover blank-line verse splitting
  • The rendered PDF shows visible spacing between stanzas for songs using blank-line separation

Example

Input:

{title: Am Brunnen vor dem Tore}

Am [D]Brunnen vor dem Tore...
Ich [D]träumt in seinem Schatten...

Ich musst auch heute wandern...
Da hab ich noch im Dunkeln...

Should produce 2 sections (two VERSE sections), not 1.

## Description The ChordPro parser (`ChordProParser.kt`, line 76) skips blank lines with `if (line.isBlank()) continue`. This means that songs which use blank lines to separate stanzas (without explicit `{start_of_verse}`/`{end_of_verse}` directives) are parsed as a **single section** containing all lyrics. This is the standard way stanzas are separated in ChordPro files, and the actual song files in the project confirm this pattern — e.g. `am-brunnen-vor-dem-tore.chopro` has three stanzas separated by blank lines, but no section directives. As a result, `verseSpacing` (the gap between sections) is never applied between stanzas, making the rendered output appear as one continuous block of text. ## Root Cause `ChordProParser.kt:76`: ```kotlin if (line.isBlank()) continue ``` When inside an implicit verse (no explicit `{start_of_verse}` was used, but `currentType` was set to `VERSE` at line 162-163), a blank line should **flush the current section** and allow the next non-blank line to start a new implicit verse. ## Acceptance Criteria - [ ] When the parser encounters a blank line while inside an implicit verse section (started without an explicit `{start_of_verse}` directive), it flushes the current section - [ ] The next non-blank lyric line starts a new implicit VERSE section - [ ] Songs with explicit `{start_of_verse}`/`{end_of_verse}` directives still work correctly (blank lines within explicit sections should be ignored, as the section boundary is explicit) - [ ] Blank lines between metadata directives (before any lyrics) do not create empty sections - [ ] Existing tests pass, new tests cover blank-line verse splitting - [ ] The rendered PDF shows visible spacing between stanzas for songs using blank-line separation ## Example Input: ``` {title: Am Brunnen vor dem Tore} Am [D]Brunnen vor dem Tore... Ich [D]träumt in seinem Schatten... Ich musst auch heute wandern... Da hab ich noch im Dunkeln... ``` Should produce **2 sections** (two VERSE sections), not 1.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shahondin1624/songbook#29