mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-26 18:26:09 +01:00
🎨 Clean code
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
f6e9ed5b55
commit
d5f7bf2c02
2 changed files with 5 additions and 1 deletions
|
|
@ -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) // 剔除前后的空白字符
|
||||
|
|
|
|||
|
|
@ -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) ||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue