mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🧑💻 Improve API exportMdContent https://github.com/siyuan-note/siyuan/issues/14032
This commit is contained in:
parent
9b2f439675
commit
5fca28ca81
2 changed files with 34 additions and 3 deletions
|
@ -410,7 +410,22 @@ func exportMdContent(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
hPath, content := model.ExportMarkdownContent(id)
|
||||
refMode := model.Conf.Export.BlockRefMode
|
||||
if nil != arg["refMode"] {
|
||||
refMode = arg["refMode"].(int)
|
||||
}
|
||||
|
||||
embedMode := model.Conf.Export.BlockEmbedMode
|
||||
if nil != arg["embedMode"] {
|
||||
embedMode = arg["embedMode"].(int)
|
||||
}
|
||||
|
||||
yfm := true
|
||||
if nil != arg["yfm"] {
|
||||
yfm = arg["yfm"].(bool)
|
||||
}
|
||||
|
||||
hPath, content := model.ExportMarkdownContent(id, refMode, embedMode, yfm)
|
||||
ret.Data = map[string]interface{}{
|
||||
"hPath": hPath,
|
||||
"content": content,
|
||||
|
|
|
@ -1925,8 +1925,24 @@ func walkRelationAvs(avID string, exportAvIDs *hashset.Set) {
|
|||
}
|
||||
}
|
||||
|
||||
func ExportMarkdownContent(id string) (hPath, exportedMd string) {
|
||||
return exportMarkdownContent(id, ".md", Conf.Export.BlockRefMode, nil, true, &map[string]*parse.Tree{})
|
||||
func ExportMarkdownContent(id string, refMode, embedMode int, addYfm bool) (hPath, exportedMd string) {
|
||||
bt := treenode.GetBlockTree(id)
|
||||
if nil == bt {
|
||||
return
|
||||
}
|
||||
|
||||
tree := prepareExportTree(bt)
|
||||
hPath = tree.HPath
|
||||
exportedMd = exportMarkdownContent0(tree, "", false,
|
||||
".md", refMode, embedMode, Conf.Export.FileAnnotationRefMode,
|
||||
Conf.Export.TagOpenMarker, Conf.Export.TagCloseMarker,
|
||||
Conf.Export.BlockRefTextLeft, Conf.Export.BlockRefTextRight,
|
||||
Conf.Export.AddTitle, nil, true, &map[string]*parse.Tree{})
|
||||
docIAL := parse.IAL2Map(tree.Root.KramdownIAL)
|
||||
if addYfm {
|
||||
exportedMd = yfm(docIAL) + exportedMd
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func exportMarkdownContent(id, ext string, exportRefMode int, defBlockIDs []string, singleFile bool, treeCache *map[string]*parse.Tree) (hPath, exportedMd string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue