Skip to content

Commit

Permalink
Only add a section page when header is not empty (#46)
Browse files Browse the repository at this point in the history
* Only add a section page when header is not empty

* Fix unit tests
  • Loading branch information
laenzlinger authored May 30, 2024
1 parent 0a96939 commit e13e84b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
6 changes: 5 additions & 1 deletion internal/gig/gig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ func TestNew(t *testing.T) {
Name: "MyBand @ Grand Ole Opry",
Sections: []Section{
{
Header: []byte("# Set 1\n\nSay Hello"),
Header: []byte{},
SongTitles: []string{"Preamble"},
},
{
Header: []byte("\n\n# Set 1\n\nSay Hello"),
SongTitles: []string{"Frankie and Johnnie", "On the Alamo", "Her Song"},
},
{
Expand Down
1 change: 1 addition & 0 deletions internal/repertoire/repertoire_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TestNew(t *testing.T) {
{Title: "On the Alamo"},
{Title: "Frankie and Johnnie"},
{Title: "Nowhere to go"},
{Title: "Preamble"},
{Title: "Her Song"},
},
},
Expand Down
14 changes: 8 additions & 6 deletions internal/sheet/sheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,15 @@ func ForGig(band config.Band, gig gig.Gig) error {
sh := sectionHeaders{}
for _, section := range gig.Sections {
h := section.HeaderText()
sh.add(h)
html, err := section.HeaderHTML()
if err != nil {
return err
if h != "" {
sh.add(h)
html, err := section.HeaderHTML()
if err != nil {
return err
}
header := Sheet{band: band, name: sh.filename(h), content: html}
sheets = append(sheets, header)
}
header := Sheet{band: band, name: sh.filename(h), content: html}
sheets = append(sheets, header)
for _, title := range section.SongTitles {
song := Sheet{band: band, name: title, content: title}
sheets = append(sheets, song)
Expand Down
3 changes: 3 additions & 0 deletions test/Repertoire/Band/Gigs/Grand Ole Opry.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Preamble

# Set 1

Say Hello
Expand All @@ -7,4 +9,5 @@ Say Hello
* Her Song

# Encore

* Nowhere To Go
4 changes: 2 additions & 2 deletions test/Repertoire/Band/Repertoire.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
| On the Alamo | 1922 | Lyrics: Gus Kahn | Isham Jones | Chris Lae | 3m 2s |
| Frankie and Johnnie | 1904 | | Hughie Cannon | Chris Lae | 2m 30s |
| Nowhere to go | 2024 | Instrumental | Chris Lae | Chris Lae | 7m |
| [[Her Song]] | 2024 | | Unknown | Chris Lae | 55s |

| Preamble | 2024 | Get started | Chris Lae | Chris Lae | 1m |
| [[Her Song]] | 2024 | | Unknown | Chris Lae | 55s |

0 comments on commit e13e84b

Please sign in to comment.