🎨 Remove invisible characters when entering document title https://github.com/siyuan-note/siyuan/issues/9493

This commit is contained in:
Daniel 2023-10-24 01:36:25 +08:00
parent 3427b83361
commit d8bb02fb20
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
6 changed files with 32 additions and 26 deletions

View file

@ -16,7 +16,11 @@
package util
import "regexp"
import (
"regexp"
"github.com/88250/gulu"
)
var emojiRegex = regexp.MustCompile(`/([0-9#][\x{20E3}])|` +
`[\x{00ae}\x{00a9}\x{203C}\x{2047}\x{2048}\x{2049}\x{3030}\x{303D}\x{2139}\x{2122}\x{3297}\x{3299}]|` +
@ -37,6 +41,8 @@ var emojiRegex = regexp.MustCompile(`/([0-9#][\x{20E3}])|` +
`[\x{2700}-\x{27BF}]|` +
`[\x{10000}-\x{E01EF}]`)
func RemoveEmoji(text string) string {
return emojiRegex.ReplaceAllString(text, "")
func RemoveEmojiInvisible(text string) (ret string) {
ret = emojiRegex.ReplaceAllString(text, "")
ret = gulu.Str.RemoveInvisible(ret)
return
}