mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-11 20:03:58 +02:00
markup/goldmark: Change link and image render hook enablement to enums
Closes #13535
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
b8ba33ca95
commit
84b31721bf
@@ -255,6 +255,27 @@ func SliceToLower(s []string) []string {
|
||||
return l
|
||||
}
|
||||
|
||||
// StringSliceToList formats a string slice into a human-readable list.
|
||||
// It joins the elements of the slice s with commas, using an Oxford comma,
|
||||
// and precedes the final element with the conjunction c.
|
||||
func StringSliceToList(s []string, c string) string {
|
||||
const defaultConjunction = "and"
|
||||
|
||||
if c == "" {
|
||||
c = defaultConjunction
|
||||
}
|
||||
if len(s) == 0 {
|
||||
return ""
|
||||
}
|
||||
if len(s) == 1 {
|
||||
return s[0]
|
||||
}
|
||||
if len(s) == 2 {
|
||||
return fmt.Sprintf("%s %s %s", s[0], c, s[1])
|
||||
}
|
||||
return fmt.Sprintf("%s, %s %s", strings.Join(s[:len(s)-1], ", "), c, s[len(s)-1])
|
||||
}
|
||||
|
||||
// IsWhitespace determines if the given rune is whitespace.
|
||||
func IsWhitespace(r rune) bool {
|
||||
return r == ' ' || r == '\t' || r == '\n' || r == '\r'
|
||||
|
Reference in New Issue
Block a user