mirror of
https://github.com/cheat/cheat.git
synced 2026-03-07 11:13:33 +01:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user