mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 08:30:42 +02:00
This commit is contained in:
parent
8707f07d8a
commit
068c03f9d7
2 changed files with 24 additions and 16 deletions
|
@ -42,7 +42,7 @@ func copyStdMarkdown(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
id := arg["id"].(string)
|
id := arg["id"].(string)
|
||||||
ret.Data = model.CopyStdMarkdown(id)
|
ret.Data = model.ExportStdMarkdown(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func html2BlockDOM(c *gin.Context) {
|
func html2BlockDOM(c *gin.Context) {
|
||||||
|
|
|
@ -93,7 +93,7 @@ func Export2Liandi(id string) (err error) {
|
||||||
|
|
||||||
title := path.Base(tree.HPath)
|
title := path.Base(tree.HPath)
|
||||||
tags := tree.Root.IALAttr("tags")
|
tags := tree.Root.IALAttr("tags")
|
||||||
content := exportMarkdownContent0(tree)
|
content := exportMarkdownContent0(tree, "https://b3logfile.com/siyuan/")
|
||||||
var result = gulu.Ret.NewResult()
|
var result = gulu.Ret.NewResult()
|
||||||
request := httpclient.NewCloudRequest30s()
|
request := httpclient.NewCloudRequest30s()
|
||||||
request = request.
|
request = request.
|
||||||
|
@ -123,7 +123,7 @@ func Export2Liandi(id string) (err error) {
|
||||||
if 0 != result.Code {
|
if 0 != result.Code {
|
||||||
msg := fmt.Sprintf("send article to liandi failed [code=%d, msg=%s]", result.Code, result.Msg)
|
msg := fmt.Sprintf("send article to liandi failed [code=%d, msg=%s]", result.Code, result.Msg)
|
||||||
logging.LogErrorf(msg)
|
logging.LogErrorf(msg)
|
||||||
return errors.New(msg)
|
return errors.New(result.Msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !foundArticle {
|
if !foundArticle {
|
||||||
|
@ -694,17 +694,18 @@ func AddPDFOutline(id, p string, merge bool) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func CopyStdMarkdown(id string) string {
|
func ExportStdMarkdown(id string) string {
|
||||||
tree, _ := loadTreeByBlockID(id)
|
tree, err := loadTreeByBlockID(id)
|
||||||
tree = exportTree(tree, false, false, false)
|
if nil != err {
|
||||||
luteEngine := NewLute()
|
logging.LogErrorf("load tree by block id [%s] failed: %s", id, err)
|
||||||
luteEngine.SetFootnotes(true)
|
return ""
|
||||||
luteEngine.SetKramdownIAL(false)
|
|
||||||
if IsSubscriber() {
|
|
||||||
// 订阅用户使用云端图床服务
|
|
||||||
luteEngine.RenderOptions.LinkBase = "https://assets.b3logfile.com/siyuan/" + Conf.User.UserId + "/"
|
|
||||||
}
|
}
|
||||||
return treenode.ExportNodeStdMd(tree.Root, luteEngine)
|
|
||||||
|
cloudAssetsBase := ""
|
||||||
|
if IsSubscriber() {
|
||||||
|
cloudAssetsBase = "https://assets.b3logfile.com/siyuan/"
|
||||||
|
}
|
||||||
|
return exportMarkdownContent0(tree, cloudAssetsBase)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExportMarkdown(id string) (name, zipPath string) {
|
func ExportMarkdown(id string) (name, zipPath string) {
|
||||||
|
@ -1132,17 +1133,24 @@ func ExportMarkdownContent(id string) (hPath, exportedMd string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func exportMarkdownContent(id string) (hPath, exportedMd string) {
|
func exportMarkdownContent(id string) (hPath, exportedMd string) {
|
||||||
tree, _ := loadTreeByBlockID(id)
|
tree, err := loadTreeByBlockID(id)
|
||||||
|
if nil != err {
|
||||||
|
logging.LogErrorf("load tree by block id [%s] failed: %s", id, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
hPath = tree.HPath
|
hPath = tree.HPath
|
||||||
exportedMd = exportMarkdownContent0(tree)
|
exportedMd = exportMarkdownContent0(tree, "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func exportMarkdownContent0(tree *parse.Tree) (ret string) {
|
func exportMarkdownContent0(tree *parse.Tree, cloudAssetsBase string) (ret string) {
|
||||||
tree = exportTree(tree, false, true, false)
|
tree = exportTree(tree, false, true, false)
|
||||||
luteEngine := NewLute()
|
luteEngine := NewLute()
|
||||||
luteEngine.SetFootnotes(true)
|
luteEngine.SetFootnotes(true)
|
||||||
luteEngine.SetKramdownIAL(false)
|
luteEngine.SetKramdownIAL(false)
|
||||||
|
if "" != cloudAssetsBase {
|
||||||
|
luteEngine.RenderOptions.LinkBase = cloudAssetsBase + Conf.User.UserId + "/"
|
||||||
|
}
|
||||||
renderer := render.NewProtyleExportMdRenderer(tree, luteEngine.RenderOptions)
|
renderer := render.NewProtyleExportMdRenderer(tree, luteEngine.RenderOptions)
|
||||||
ret = gulu.Str.FromBytes(renderer.Render())
|
ret = gulu.Str.FromBytes(renderer.Render())
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue