Skip to content

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

:bug: 嵌入块 SQL 脚本中存在换行时无法导出 Fix https://github.com/siyuan-note/siyuan/issues/7771

Liang Ding7c7b649923f5
diff --git a/kernel/model/export.go b/kernel/model/export.go
index 3a4c17b5a5..4ef74b48d3 100644
--- a/kernel/model/export.go
+++ b/kernel/model/export.go
@@ -1561,6 +1561,7 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool,
var defMd string
stmt := n.ChildByType(ast.NodeBlockQueryEmbedScript).TokensStr()
stmt = html.UnescapeString(stmt)
+ stmt = strings.ReplaceAll(stmt, editor.IALValEscNewLine, "\n")
embedBlocks := searchEmbedBlock(n.ID, stmt, nil, 0, false)
if 1 > len(embedBlocks) {
return ast.WalkContinue
@@ -1875,6 +1876,7 @@ func resolveFootnotesDefs(refFootnotes *[]*refAsFootnotes, rootID string, blockR
} else if ast.NodeBlockQueryEmbed == n.Type {
stmt := n.ChildByType(ast.NodeBlockQueryEmbedScript).TokensStr()
stmt = html.UnescapeString(stmt)
+ stmt = strings.ReplaceAll(stmt, editor.IALValEscNewLine, "\n")
sqlBlocks := sql.SelectBlocksRawStmt(stmt, Conf.Search.Limit)
for _, b := range sqlBlocks {
subNodes := renderBlockMarkdownR0(b.ID, &rendered)
diff --git a/kernel/model/render.go b/kernel/model/render.go
index 10198ea25f..1c9ccc3bd4 100644
--- a/kernel/model/render.go
+++ b/kernel/model/render.go
@@ -18,6 +18,7 @@ package model
import (
"bytes"
+ "github.com/88250/lute/editor"
"regexp"
"strings"
@@ -203,6 +204,7 @@ func renderBlockMarkdownR0(id string, rendered *[]string) (ret []*ast.Node) {
if ast.NodeBlockQueryEmbed == n.Type {
stmt := n.ChildByType(ast.NodeBlockQueryEmbedScript).TokensStr()
stmt = html.UnescapeString(stmt)
+ stmt = strings.ReplaceAll(stmt, editor.IALValEscNewLine, "\n")
sqlBlocks := sql.SelectBlocksRawStmt(stmt, Conf.Search.Limit)
for _, sqlBlock := range sqlBlocks {
subNodes := renderBlockMarkdownR0(sqlBlock.ID, rendered)