refactor(Sheet): create parse method

Move `Frontmatter.Parse` to `Sheet.parse`, and delete the `frontmatter`
package. `Sheet.parse` more accurately describes the parser's behavior.
This commit is contained in:
Christopher Allen Lane
2022-08-26 12:20:58 -04:00
parent f0bfeda47a
commit 2d635293c5
3 changed files with 19 additions and 21 deletions

View File

@@ -4,10 +4,14 @@ import (
"fmt"
"os"
"sort"
"github.com/cheat/cheat/internal/frontmatter"
)
// Frontmatter encapsulates cheatsheet frontmatter data
type frontmatter struct {
Tags []string
Syntax string
}
// Sheet encapsulates sheet information
type Sheet struct {
Title string
@@ -34,8 +38,8 @@ func New(
return Sheet{}, fmt.Errorf("failed to read file: %s, %v", path, err)
}
// parse the cheatsheet frontmatter
text, fm, err := frontmatter.Parse(string(markdown))
// parse the raw cheatsheet text
fm, text, err := parse(string(markdown))
if err != nil {
return Sheet{}, fmt.Errorf("failed to parse front-matter: %v", err)
}