From bf0b9df04fd47dae9eb5fcc8f87ae7c215acbe06 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 24 Nov 2022 18:07:36 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=AF=BC=E5=85=A5=20Markdown=20?= =?UTF-8?q?=E6=97=B6=E6=94=AF=E6=8C=81=E5=9B=BE=E7=89=87=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=8C=85=E5=90=AB=E7=A9=BA=E6=A0=BC=20Fix=20https://github.com?= =?UTF-8?q?/siyuan-note/siyuan/issues/6688?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/box.go | 1 + kernel/model/import.go | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/kernel/model/box.go b/kernel/model/box.go index caa715c69..b42a50fbc 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 1336b8f84..5abe655f9 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