🎨 Update av

This commit is contained in:
Daniel 2023-07-03 15:29:54 +08:00
parent fb85f7d36e
commit f91d6cbce9
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 52 additions and 13 deletions

View file

@ -24,6 +24,18 @@ import (
"github.com/88250/lute/html"
)
// InsertElement inserts a new element value at the specified index position.
// 0 <= index <= len(a)
func InsertElement[T any](ret []T, index int, value T) []T {
if len(ret) == index { // nil or empty slice or after last element
return append(ret, value)
}
ret = append(ret[:index+1], ret[index:]...) // index < len(a)
ret[index] = value
return ret
}
func EscapeHTML(s string) string {
if strings.Contains(s, "&amp;") {
return s