Skip to content

Commit

Permalink
Move song header into separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
laenzlinger committed Apr 4, 2024
1 parent 833b93f commit ba6b092
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 32 deletions.
37 changes: 37 additions & 0 deletions internal/song/header.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package song

import (
"github.com/yuin/goldmark/ast"
)

type Header struct {
tableHeader *ast.Node
}

func NewHeader(h *ast.Node) Header {
return Header{tableHeader: h}
}

func (h Header) Remove() Header {
h.tableHeader = nil
return h
}

func (h Header) RemoveColumns(idx Indexes) Header {
if !h.Empty() {
removed := RemoveCols(idx, *h.tableHeader)
h.tableHeader = &removed
}
return h
}

func (h Header) Empty() bool {
return h.tableHeader == nil
}

func (h Header) Node() ast.Node {
if h.Empty() {
return ast.NewText()
}
return *h.tableHeader
}
32 changes: 0 additions & 32 deletions internal/song/song.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,3 @@ func (s Song) RemoveColumns(idx Indexes) Song {
s.TableRow = RemoveCols(idx, s.TableRow)
return s
}

type Header struct {
tableHeader *ast.Node
}

func NewHeader(h *ast.Node) Header {
return Header{tableHeader: h}
}

func (h Header) Remove() Header {
h.tableHeader = nil
return h
}

func (h Header) RemoveColumns(idx Indexes) Header {
if !h.Empty() {
removed := RemoveCols(idx, *h.tableHeader)
h.tableHeader = &removed
}
return h
}

func (h Header) Empty() bool {
return h.tableHeader == nil
}

func (h Header) Node() ast.Node {
if h.Empty() {
return ast.NewText()
}
return *h.tableHeader
}

0 comments on commit ba6b092

Please sign in to comment.