🎨 Clean code

Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2026-01-20 10:05:28 +08:00
parent f6e9ed5b55
commit d5f7bf2c02
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 5 additions and 1 deletions

View file

@ -253,7 +253,7 @@ func parseKeywords(keywordsStr string) (keywords []string) {
// 先处理转义的逗号
keywordsStr = strings.ReplaceAll(keywordsStr, "\\,", "__comma@sep__")
// 再将连续或单个换行符替换为一个逗号,避免把 `\\\n` 转换为 `\,`
keywordsStr = regexp.MustCompile(`[\r\n]+`).ReplaceAllString(keywordsStr, ",")
keywordsStr = util.ReplaceNewline(keywordsStr, ",")
// 按逗号分隔
for part := range strings.SplitSeq(keywordsStr, ",") {
part = strings.TrimSpace(part) // 剔除前后的空白字符

View file

@ -27,6 +27,10 @@ import (
"github.com/siyuan-note/logging"
)
func ReplaceNewline(text, replaceWith string) string {
return regexp.MustCompile(`[\r\n]+`).ReplaceAllString(text, replaceWith)
}
func ContainsCJK(text string) bool {
for _, r := range text {
ret := unicode.Is(unicode.Han, r) || unicode.Is(unicode.Lm, r) ||