An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:technologist: Add parameter `imgTag` for kernel API `exportMdContent` and `copyStdMarkdown` https://github.com/siyuan-note/siyuan/issues/15454
Daniel99fca2f716fd
diff --git a/kernel/api/export.go b/kernel/api/export.goindex 19cd1057bf..4c64914dc1 100644--- a/kernel/api/export.go+++ b/kernel/api/export.go@@ -437,7 +437,12 @@ func exportMdContent(c *gin.Context) {adjustHeadingLevel = arg["adjustHeadingLevel"].(bool)}- hPath, content := model.ExportMarkdownContent(id, refMode, embedMode, yfm, fillCSSVar, adjustHeadingLevel)+ imgTag := false+ if nil != arg["imgTag"] {+ imgTag = arg["imgTag"].(bool)+ }++ hPath, content := model.ExportMarkdownContent(id, refMode, embedMode, yfm, fillCSSVar, adjustHeadingLevel, imgTag)ret.Data = map[string]interface{}{"hPath": hPath,"content": content,diff --git a/kernel/api/lute.go b/kernel/api/lute.goindex 208ada64c4..4c63849c8d 100644--- a/kernel/api/lute.go+++ b/kernel/api/lute.go@@ -59,7 +59,12 @@ func copyStdMarkdown(c *gin.Context) {adjustHeadingLevel = arg["adjustHeadingLevel"].(bool)}- ret.Data = model.ExportStdMarkdown(id, assetsDestSpace2Underscore, fillCSSVar, adjustHeadingLevel)+ imgTag := false+ if nil != arg["imgTag"] {+ imgTag = arg["imgTag"].(bool)+ }++ ret.Data = model.ExportStdMarkdown(id, assetsDestSpace2Underscore, fillCSSVar, adjustHeadingLevel, imgTag)}func html2BlockDOM(c *gin.Context) {diff --git a/kernel/go.mod b/kernel/go.modindex 42bdba4091..5c6f52fcb9 100644--- a/kernel/go.mod+++ b/kernel/go.mod@@ -8,7 +8,7 @@ require (github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7github.com/88250/gulu v1.2.3-0.20250227144607-7f4570b0d689- github.com/88250/lute v1.7.7-0.20250807111935-2082cd962215+ github.com/88250/lute v1.7.7-0.20250807121338-5e107ba6c37cgithub.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4github.com/ConradIrwin/font v0.2.1diff --git a/kernel/go.sum b/kernel/go.sumindex c5d4405df3..1787c806f4 100644--- a/kernel/go.sum+++ b/kernel/go.sum@@ -14,8 +14,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceTgithub.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=github.com/88250/gulu v1.2.3-0.20250227144607-7f4570b0d689 h1:39y5g7vnFAIcXhTN3IXPk7h2xBhC4a9hBTykDhHJqRY=github.com/88250/gulu v1.2.3-0.20250227144607-7f4570b0d689/go.mod h1:c8uVw25vW2W4dhJ/j4iYsX5H1hc19spim266jO5x2hU=-github.com/88250/lute v1.7.7-0.20250807111935-2082cd962215 h1:mJ3ilLbCYThH1RwFNFU64uA7lCT3XtKAnVOEP+kz9NQ=-github.com/88250/lute v1.7.7-0.20250807111935-2082cd962215/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o=+github.com/88250/lute v1.7.7-0.20250807121338-5e107ba6c37c h1:RzJLUTtxklE75Hf8YxrT9nsRKZTK34AA5nnLPjZ4lpM=+github.com/88250/lute v1.7.7-0.20250807121338-5e107ba6c37c/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o=github.com/88250/pdfcpu v0.3.14-0.20250424122812-f10e8d9d8d46 h1:Bq1JsDfVbHKUxNL/B2JXd8cC/1h6aFjrlXpGycnh0Hk=github.com/88250/pdfcpu v0.3.14-0.20250424122812-f10e8d9d8d46/go.mod h1:fVfOloBzs2+W2VJCCbq60XIxc3yJHAZ0Gahv1oO0gyI=github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=diff --git a/kernel/model/export.go b/kernel/model/export.goindex 835f9aaa36..f58fb33802 100644--- a/kernel/model/export.go+++ b/kernel/model/export.go@@ -268,7 +268,8 @@ func Export2Liandi(id string) (err error) {title := path.Base(tree.HPath)tags := tree.Root.IALAttr("tags")- content := exportMarkdownContent0(id, tree, util.GetCloudForumAssetsServer()+time.Now().Format("2006/01")+"/siyuan/"+Conf.GetUser().UserId+"/", true, false,+ content := exportMarkdownContent0(id, tree, util.GetCloudForumAssetsServer()+time.Now().Format("2006/01")+"/siyuan/"+Conf.GetUser().UserId+"/",+ true, false, false,".md", 3, 1, 1,"#", "#","", "",@@ -1459,7 +1460,7 @@ func processPDFLinkEmbedAssets(pdfCtx *model.Context, assetDests []string, remov}}-func ExportStdMarkdown(id string, assetsDestSpace2Underscore, fillCSSVar, adjustHeadingLevel bool) string {+func ExportStdMarkdown(id string, assetsDestSpace2Underscore, fillCSSVar, adjustHeadingLevel, imgTag bool) string {bt := treenode.GetBlockTree(id)if nil == bt {logging.LogErrorf("block tree [%s] not found", id)@@ -1498,7 +1499,7 @@ func ExportStdMarkdown(id string, assetsDestSpace2Underscore, fillCSSVar, adjust}defBlockIDs = gulu.Str.RemoveDuplicatedElem(defBlockIDs)- return exportMarkdownContent0(id, tree, cloudAssetsBase, assetsDestSpace2Underscore, adjustHeadingLevel,+ return exportMarkdownContent0(id, tree, cloudAssetsBase, assetsDestSpace2Underscore, adjustHeadingLevel, imgTag,".md", Conf.Export.BlockRefMode, Conf.Export.BlockEmbedMode, Conf.Export.FileAnnotationRefMode,Conf.Export.TagOpenMarker, Conf.Export.TagCloseMarker,Conf.Export.BlockRefTextLeft, Conf.Export.BlockRefTextRight,@@ -1984,7 +1985,7 @@ func walkRelationAvs(avID string, exportAvIDs *hashset.Set) {}}-func ExportMarkdownContent(id string, refMode, embedMode int, addYfm, fillCSSVar, adjustHeadingLv bool) (hPath, exportedMd string) {+func ExportMarkdownContent(id string, refMode, embedMode int, addYfm, fillCSSVar, adjustHeadingLv, imgTag bool) (hPath, exportedMd string) {bt := treenode.GetBlockTree(id)if nil == bt {return@@ -1992,7 +1993,7 @@ func ExportMarkdownContent(id string, refMode, embedMode int, addYfm, fillCSSVartree := prepareExportTree(bt)hPath = tree.HPath- exportedMd = exportMarkdownContent0(id, tree, "", false, adjustHeadingLv,+ exportedMd = exportMarkdownContent0(id, tree, "", false, adjustHeadingLv, imgTag,".md", refMode, embedMode, Conf.Export.FileAnnotationRefMode,Conf.Export.TagOpenMarker, Conf.Export.TagCloseMarker,Conf.Export.BlockRefTextLeft, Conf.Export.BlockRefTextRight,@@ -2015,7 +2016,7 @@ func exportMarkdownContent(id, ext string, exportRefMode int, defBlockIDs []striisEmpty = nil == tree.Root.FirstChild.FirstChild}- exportedMd = exportMarkdownContent0(id, tree, "", false, false,+ exportedMd = exportMarkdownContent0(id, tree, "", false, false, false,ext, exportRefMode, Conf.Export.BlockEmbedMode, Conf.Export.FileAnnotationRefMode,Conf.Export.TagOpenMarker, Conf.Export.TagCloseMarker,Conf.Export.BlockRefTextLeft, Conf.Export.BlockRefTextRight,@@ -2028,7 +2029,7 @@ func exportMarkdownContent(id, ext string, exportRefMode int, defBlockIDs []strireturn}-func exportMarkdownContent0(id string, tree *parse.Tree, cloudAssetsBase string, assetsDestSpace2Underscore, adjustHeadingLv bool,+func exportMarkdownContent0(id string, tree *parse.Tree, cloudAssetsBase string, assetsDestSpace2Underscore, adjustHeadingLv, imgTag bool,ext string, blockRefMode, blockEmbedMode, fileAnnotationRefMode int,tagOpenMarker, tagCloseMarker string, blockRefTextLeft, blockRefTextRight string,addTitle, inlineMemo bool, defBlockIDs []string, singleFile, fillCSSVar bool, treeCache *map[string]*parse.Tree) (ret string) {@@ -2148,6 +2149,7 @@ func exportMarkdownContent0(id string, tree *parse.Tree, cloudAssetsBase string,}luteEngine.SetUnorderedListMarker("-")+ luteEngine.SetImgTag(imgTag)renderer := render.NewProtyleExportMdRenderer(tree, luteEngine.RenderOptions)ret = gulu.Str.FromBytes(renderer.Render())return