Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Clean code

Danielffd947233e46
diff --git a/kernel/util/rune.go b/kernel/util/rune.go
index 6533508f00..1617a3b390 100644
--- a/kernel/util/rune.go
+++ b/kernel/util/rune.go
@@ -27,8 +27,10 @@ import (
"github.com/siyuan-note/logging"
)
+var newlinesRegex = regexp.MustCompile(`[\r\n]+`)
+
func ReplaceNewline(text, replaceWith string) string {
- return regexp.MustCompile(`[\r\n]+`).ReplaceAllString(text, replaceWith)
+ return newlinesRegex.ReplaceAllString(text, replaceWith)
}
func ContainsCJK(text string) bool {