func Filter(
	cheatpaths []map[string]sheet.Sheet,
	tags []string,
) []map[string]sheet.Sheet {

	// buffer a map of filtered cheatsheets
	filtered := make([]map[string]sheet.Sheet, 0, len(cheatpaths))

	// iterate over each cheatpath
	for _, cheatsheets := range cheatpaths {

		// create a map of cheatsheets for each cheatpath. The filtering will be
		// applied to each cheatpath individually.
		pathFiltered := make(map[string]sheet.Sheet)

		// iterate over each cheatsheet that exists on each cheatpath
		for title, sheet := range cheatsheets {

			// assume that the sheet should be kept (ie, should not be filtered)
			keep := true

			// iterate over each tag. If the sheet does not match *all* tags, filter
			// it out.
			for _, tag := range tags {
				if !sheet.Tagged(strings.TrimSpace(tag)) {
					keep = false
				}
			}

			// if the sheet does match all tags, it passes the filter
			if keep {
				pathFiltered[title] = sheet
			}
		}

		// the sheets on this individual cheatpath have now been filtered. Now,
		// store those alongside the sheets on the other cheatpaths that also made
		// it passed the filter.
		filtered = append(filtered, pathFiltered)
	}

	// return the filtered cheatsheets on all paths
	return filtered
}
// Filter filters cheatsheets that do not match `tag(s)`
Filter filters cheatsheets that do not match `tag(s)`
// Filter filters cheatsheets that do not match ` tag ( s ) `
func Filter(
	cheatpaths []map[string]sheet.Sheet,
	tags []string,
) []map[string]sheet.Sheet {
	filtered := make([]map[string]sheet.Sheet, 0, len(cheatpaths))
	for _, cheatsheets := range cheatpaths {
		pathFiltered := make(map[string]sheet.Sheet)
		for title, sheet := range cheatsheets {
			keep := true
			for _, tag := range tags {
				if !sheet.Tagged(strings.TrimSpace(tag)) {
					keep = false
				}
			}
			if keep {
				pathFiltered[title] = sheet
			}
		}
		filtered = append(filtered, pathFiltered)
	}
	return filtered
}
func Filter ( cheatpaths [ ] map [ string ] sheet . Sheet , tags [ ] string , ) [ ] map [ string ] sheet . Sheet { filtered := make ( [ ] map [ string ] sheet . Sheet , 0 , len ( cheatpaths ) ) for _ , cheatsheets := range cheatpaths { pathFiltered := make ( map [ string ] sheet . Sheet ) for title , sheet := range cheatsheets { keep := true for _ , tag := range tags { if ! sheet . Tagged ( strings . TrimSpace ( tag ) ) { keep = false } } if keep { pathFiltered [ title ] = sheet } } filtered = append ( filtered , pathFiltered ) } return filtered }
Filter filters cheatsheets that do not match `tag(s)`
Filter filters cheatsheets that do not match ` tag ( s ) `
// buffer a map of filtered cheatsheets // iterate over each cheatpath // create a map of cheatsheets for each cheatpath. The filtering will be // applied to each cheatpath individually. // iterate over each cheatsheet that exists on each cheatpath // assume that the sheet should be kept (ie, should not be filtered) // iterate over each tag. If the sheet does not match *all* tags, filter // it out. // if the sheet does match all tags, it passes the filter // the sheets on this individual cheatpath have now been filtered. Now, // store those alongside the sheets on the other cheatpaths that also made // it passed the filter. // return the filtered cheatsheets on all paths