chore: fix UI
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"html"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var htmlTagRe = regexp.MustCompile(`<[^>]*>`)
|
||||
|
||||
// StripHTML removes HTML tags and decodes HTML entities from s.
|
||||
func StripHTML(s string) string {
|
||||
stripped := htmlTagRe.ReplaceAllString(s, "")
|
||||
decoded := html.UnescapeString(stripped)
|
||||
return StripCRLF(decoded)
|
||||
}
|
||||
|
||||
func StripCRLF(s string) string {
|
||||
return strings.TrimSpace(strings.Map(func(r rune) rune {
|
||||
if r == '\r' || r == '\n' {
|
||||
return -1
|
||||
}
|
||||
return r
|
||||
}, s))
|
||||
}
|
||||
Reference in New Issue
Block a user