Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only add a section page when header is not empty #46

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |