1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-15 14:30:26 +00:00
mycorrhiza/markup/utils.go

24 lines
600 B
Go
Raw Normal View History

2020-10-30 13:25:48 +00:00
package markup
import (
"strings"
)
// Function that returns a function that can strip `prefix` and trim whitespace when called.
func remover(prefix string) func(string) string {
return func(l string) string {
return strings.TrimSpace(strings.TrimPrefix(l, prefix))
}
}
// Remove #, ## or ### from beginning of `line`.
func removeHeadingOctothorps(line string) string {
f := remover("#")
return f(f(f(line)))
}
// Return a canonical representation of a hypha `name`.
func canonicalName(name string) string {
return strings.ToLower(strings.ReplaceAll(strings.TrimSpace(name), " ", "_"))
}