2022-12-22 19:06:57 +00:00
|
|
|
package svg
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"bytes"
|
2025-01-28 16:16:14 +00:00
|
|
|
"encoding/base32"
|
2022-12-22 19:06:57 +00:00
|
|
|
"encoding/xml"
|
2025-01-28 16:16:14 +00:00
|
|
|
"strings"
|
2022-12-22 19:06:57 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func EscapeText(text string) string {
|
|
|
|
|
buf := new(bytes.Buffer)
|
|
|
|
|
_ = xml.EscapeText(buf, []byte(text))
|
|
|
|
|
return buf.String()
|
|
|
|
|
}
|
2025-01-28 16:16:14 +00:00
|
|
|
|
|
|
|
|
func SVGID(text string) string {
|
|
|
|
|
return strings.TrimRight(base32.StdEncoding.EncodeToString([]byte(text)), "=")
|
|
|
|
|
}
|