mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
@@ -14,6 +14,7 @@
|
||||
package text
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
"unicode"
|
||||
|
||||
@@ -45,3 +46,18 @@ func RemoveAccentsString(s string) string {
|
||||
accentTransformerPool.Put(t)
|
||||
return s
|
||||
}
|
||||
|
||||
// Chomp removes trailing newline characters from s.
|
||||
func Chomp(s string) string {
|
||||
return strings.TrimRightFunc(s, func(r rune) bool {
|
||||
return r == '\n' || r == '\r'
|
||||
})
|
||||
}
|
||||
|
||||
// Puts adds a trailing \n none found.
|
||||
func Puts(s string) string {
|
||||
if s == "" || s[len(s)-1] == '\n' {
|
||||
return s
|
||||
}
|
||||
return s + "\n"
|
||||
}
|
||||
|
Reference in New Issue
Block a user