From 7ddf99dab8cf3a597108632acb97d1a2039396ff Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 16 Mar 2023 10:08:11 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=AF=BC=E5=85=A5=20Markdown=20?= =?UTF-8?q?=E6=97=B6=E4=B8=8D=E8=87=AA=E5=8A=A8=E8=BD=AC=E6=8D=A2=E8=B6=85?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=20Fix=20https://github.com/siyuan-note/siyua?= =?UTF-8?q?n/issues/7682?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/box.go | 17 ----------------- kernel/model/import.go | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/kernel/model/box.go b/kernel/model/box.go index 639c17651..8f943f549 100644 --- a/kernel/model/box.go +++ b/kernel/model/box.go @@ -30,7 +30,6 @@ import ( "time" "github.com/88250/gulu" - "github.com/88250/lute" "github.com/88250/lute/ast" "github.com/88250/lute/parse" "github.com/dustin/go-humanize" @@ -403,22 +402,6 @@ func (box *Box) moveTrees0(files []*FileInfo) { } } -func parseStdMd(markdown []byte) (ret *parse.Tree) { - luteEngine := lute.New() - luteEngine.SetFootnotes(false) - luteEngine.SetToC(false) - luteEngine.SetIndentCodeBlock(false) - luteEngine.SetAutoSpace(false) - luteEngine.SetHeadingID(false) - luteEngine.SetSetext(false) - luteEngine.SetYamlFrontMatter(false) - luteEngine.SetLinkRef(false) - luteEngine.SetImgPathAllowSpace(true) - ret = parse.Parse("", markdown, luteEngine.ParseOptions) - genTreeID(ret) - return -} - func parseKTree(kramdown []byte) (ret *parse.Tree) { luteEngine := NewLute() ret = parse.Parse("", kramdown, luteEngine.ParseOptions) diff --git a/kernel/model/import.go b/kernel/model/import.go index ad1c4234d..37b314217 100644 --- a/kernel/model/import.go +++ b/kernel/model/import.go @@ -38,6 +38,7 @@ import ( "time" "github.com/88250/gulu" + "github.com/88250/lute" "github.com/88250/lute/ast" "github.com/88250/lute/html" "github.com/88250/lute/html/atom" @@ -705,6 +706,23 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) { return } +func parseStdMd(markdown []byte) (ret *parse.Tree) { + luteEngine := lute.New() + luteEngine.SetFootnotes(false) + luteEngine.SetToC(false) + luteEngine.SetIndentCodeBlock(false) + luteEngine.SetAutoSpace(false) + luteEngine.SetHeadingID(false) + luteEngine.SetSetext(false) + luteEngine.SetYamlFrontMatter(false) + luteEngine.SetLinkRef(false) + luteEngine.SetGFMAutoLink(false) // 导入 Markdown 时不自动转换超链接 https://github.com/siyuan-note/siyuan/issues/7682 + luteEngine.SetImgPathAllowSpace(true) + ret = parse.Parse("", markdown, luteEngine.ParseOptions) + genTreeID(ret) + return +} + func processBase64Img(n *ast.Node, dest string, assetDirPath string, err error) { base64TmpDir := filepath.Join(util.TempDir, "base64") os.MkdirAll(base64TmpDir, 0755)