package util
import "git.sr.ht/~bouncepaw/mycomarkup/v5/util"
Package util provides simple utility functions usable in all modules.
Index ¶
- func BeautifulName(uglyName string) string
- func CanonicalName(name string) string
- func DefaultString(s, d string) string
- func SanitizedName(unsafeName string) string
- func StringID(s string) string
- func TernaryConditionString(cond bool, thenBranch, elseBranch string) string
- func ValidURL(s string) bool
Functions ¶
func BeautifulName ¶
BeautifulName makes the ugly name beautiful by replacing _ with spaces and using title case
func CanonicalName ¶
CanonicalName returns the canonical form of the name. A name is canonical if it is lowercase, all left and right whitespace is trimmed and all spaces are replaced with underscores.
func DefaultString ¶
DefaultString returns d if s is an empty string, s otherwise.
func SanitizedName ¶
SanitizedName is unsafeName with all unsafe characters removed.
func StringID ¶
StringID sanitizes the string and makes it more suitable for the id attribute in HTML.
func TernaryConditionString ¶
TernaryConditionString is an approximation of an expression like (cond ? thenBranch : elseBranch) from other programming languages. There is no real need for this function, I just felt the urge to add it.
func ValidURL ¶
ValidURL is true if s is a valid absolute URL.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
util/lines | Package line provides a datatype for text lines that are generated by package tag. |
- Version
- v5.6.0 (latest)
- Published
- Nov 29, 2023
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 1 day ago –
Tools for package owners.