mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
🎨 Remove invisible characters when entering document title https://github.com/siyuan-note/siyuan/issues/9493
This commit is contained in:
parent
3427b83361
commit
d8bb02fb20
6 changed files with 32 additions and 26 deletions
48
kernel/util/rune.go
Normal file
48
kernel/util/rune.go
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// SiYuan - Refactor your thinking
|
||||
// Copyright (c) 2020-present, b3log.org
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package util
|
||||
|
||||
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}]|` +
|
||||
`[\x{2190}-\x{21FF}]|[\x{FE00}-\x{FEFF}]|` +
|
||||
`[\x{2300}-\x{23FF}]|[\x{FE00}-\x{FEFF}]|` +
|
||||
`[\x{2460}-\x{24FF}]|[\x{FE00}-\x{FEFF}]|` +
|
||||
`[\x{25A0}-\x{25FF}]|[\x{FE00}-\x{FEFF}]|` +
|
||||
`[\x{2600}-\x{27BF}]|[\x{FE00}-\x{FEFF}]|` +
|
||||
`[\x{2900}-\x{297F}]|[\x{FE00}-\x{FEFF}]|` +
|
||||
`[\x{2B00}-\x{2BF0}]|[\x{FE00}-\x{FEFF}]|` +
|
||||
`[\x{1F000}-\x{1F6FF}]|[\x{FE00}-\x{FEFF}]|` +
|
||||
`[\x{1F600}-\x{1F64F}]|` +
|
||||
`[\x{1F680}-\x{1F6FF}]|` +
|
||||
`[\x{1F900}-\x{1F9FF}]|` +
|
||||
`[\x{1F1E0}-\x{1F1FF}]|` +
|
||||
`[\x{1D100}-\x{1D1FF}]|` +
|
||||
`[\x{2600}-\x{26FF}]|` +
|
||||
`[\x{2700}-\x{27BF}]|` +
|
||||
`[\x{10000}-\x{E01EF}]`)
|
||||
|
||||
func RemoveEmojiInvisible(text string) (ret string) {
|
||||
ret = emojiRegex.ReplaceAllString(text, "")
|
||||
ret = gulu.Str.RemoveInvisible(ret)
|
||||
return
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue