Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/15377

Danielfeef48d624b0
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go
index 0734a05eb4..0f65692a2b 100644
--- a/kernel/model/transaction.go
+++ b/kernel/model/transaction.go
@@ -1440,6 +1440,19 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
cache.PutBlockIAL(updatedNode.ID, parse.IAL2Map(updatedNode.KramdownIAL))
+ if ast.NodeHTMLBlock == updatedNode.Type {
+ content := string(updatedNode.Tokens)
+ // 剔除连续的空行(包括空行内包含空格的情况) https://github.com/siyuan-note/siyuan/issues/15377
+ var newLines []string
+ lines := strings.Split(content, "\n")
+ for _, line := range lines {
+ if strings.TrimSpace(line) != "" {
+ newLines = append(newLines, line)
+ }
+ }
+ updatedNode.Tokens = []byte(strings.Join(newLines, "\n"))
+ }
+
// 替换为新节点
oldNode.InsertAfter(updatedNode)
oldNode.Unlink()