Skip to content

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

:art: 导入 Markdown 时支持图片路径包含空格 Fix https://github.com/siyuan-note/siyuan/issues/6688

Liang Dingbf0b9df04fd4
diff --git a/kernel/model/box.go b/kernel/model/box.go
index caa715c69c..b42a50fbc2 100644
--- a/kernel/model/box.go
+++ b/kernel/model/box.go
@@ -450,6 +450,7 @@ func parseStdMd(markdown []byte) (ret *parse.Tree) {
luteEngine.SetSetext(false)
luteEngine.SetYamlFrontMatter(false)
luteEngine.SetLinkRef(false)
+ luteEngine.SetImgPathAllowSpace(true)
ret = parse.Parse("", markdown, luteEngine.ParseOptions)
genTreeID(ret)
return
diff --git a/kernel/model/import.go b/kernel/model/import.go
index 1336b8f84f..5abe655f9c 100644
--- a/kernel/model/import.go
+++ b/kernel/model/import.go
@@ -518,7 +518,14 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
return ast.WalkContinue
}
- if !util.IsRelativePath(dest) || "" == dest {
+ dest = strings.ReplaceAll(dest, "%20", " ")
+ dest = strings.ReplaceAll(dest, "%5C", "/")
+ n.Tokens = []byte(dest)
+ if !util.IsRelativePath(dest) {
+ return ast.WalkContinue
+ }
+ dest = filepath.ToSlash(dest)
+ if "" == dest {
return ast.WalkContinue
}
@@ -611,10 +618,12 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
return ast.WalkContinue
}
+ dest = strings.ReplaceAll(dest, "%20", " ")
+ dest = strings.ReplaceAll(dest, "%5C", "/")
+ n.Tokens = []byte(dest)
if !util.IsRelativePath(dest) {
return ast.WalkContinue
}
-
dest = filepath.ToSlash(dest)
if "" == dest {
return ast.WalkContinue