func New(
	title string,
	cheatpath string,
	path string,
	tags []string,
	readOnly bool,
) (Sheet, error) {

	// read the cheatsheet file
	markdown, err := ioutil.ReadFile(path)
	if err != nil {
		return Sheet{}, fmt.Errorf("failed to read file: %s, %v", path, err)
	}

	// parse the cheatsheet frontmatter
	text, fm, err := frontmatter.Parse(string(markdown))
	if err != nil {
		return Sheet{}, fmt.Errorf("failed to parse front-matter: %v", err)
	}

	// merge the sheet-specific tags into the cheatpath tags
	tags = append(tags, fm.Tags...)

	// sort strings so they pretty-print nicely
	sort.Strings(tags)

	// initialize and return a sheet
	return Sheet{
		Title:     title,
		CheatPath: cheatpath,
		Path:      path,
		Text:      text + "\n",
		Tags:      tags,
		Syntax:    fm.Syntax,
		ReadOnly:  readOnly,
	}, nil
}
// New initializes a new Sheet
New initializes a new Sheet
// New initializes a new Sheet
func New(
	title string,
	cheatpath string,
	path string,
	tags []string,
	readOnly bool,
) (Sheet, error) {
	markdown, err := ioutil.ReadFile(path)
	if err != nil {
		return Sheet{}, fmt.Errorf("failed to read file: %s, %v", path, err)
	}
	text, fm, err := frontmatter.Parse(string(markdown))
	if err != nil {
		return Sheet{}, fmt.Errorf("failed to parse front-matter: %v", err)
	}
	tags = append(tags, fm.Tags...)
	sort.Strings(tags)
	return Sheet{
		Title:     title,
		CheatPath: cheatpath,
		Path:      path,
		Text:      text + "\n",
		Tags:      tags,
		Syntax:    fm.Syntax,
		ReadOnly:  readOnly,
	}, nil
}
func New ( title string , cheatpath string , path string , tags [ ] string , readOnly bool , ) ( Sheet , error ) { markdown , err := ioutil . ReadFile ( path ) if err != nil { return Sheet { } , fmt . Errorf ( " " , path , err ) } text , fm , err := frontmatter . Parse ( string ( markdown ) ) if err != nil { return Sheet { } , fmt . Errorf ( " " , err ) } tags = append ( tags , fm . Tags ... ) sort . Strings ( tags ) return Sheet { Title : title , CheatPath : cheatpath , Path : path , Text : text + " \n " , Tags : tags , Syntax : fm . Syntax , ReadOnly : readOnly , } , nil }
New initializes a new Sheet
New initializes a new Sheet
// read the cheatsheet file // parse the cheatsheet frontmatter // merge the sheet-specific tags into the cheatpath tags // sort strings so they pretty-print nicely // initialize and return a sheet