mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-10-30 19:56:16 +00:00
24 lines
600 B
Go
24 lines
600 B
Go
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), " ", "_"))
|
|
}
|