Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2026-01-25 22:10:43 +08:00
parent 09a52e44d6
commit 40ae99e278
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 19 additions and 3 deletions

View file

@ -487,7 +487,16 @@ func exportMdContent(c *gin.Context) {
imgTag = arg["imgTag"].(bool)
}
hPath, content := model.ExportMarkdownContent(id, refMode, embedMode, yfm, fillCSSVar, adjustHeadingLevel, imgTag)
addTitleMode := 0 // 0未指定遵循全局设置 Conf.Export.AddTitle1添加标题2不添加标题
if nil != arg["addTitle"] {
if arg["addTitle"].(bool) {
addTitleMode = 1
} else {
addTitleMode = 2
}
}
hPath, content := model.ExportMarkdownContent(id, refMode, embedMode, addTitleMode, yfm, fillCSSVar, adjustHeadingLevel, imgTag)
ret.Data = map[string]interface{}{
"hPath": hPath,
"content": content,

View file

@ -2221,19 +2221,26 @@ func walkRelationAvs(avID string, exportAvIDs *hashset.Set) {
}
}
func ExportMarkdownContent(id string, refMode, embedMode int, addYfm, fillCSSVar, adjustHeadingLv, imgTag bool) (hPath, exportedMd string) {
func ExportMarkdownContent(id string, refMode, embedMode, addTitleMode int, addYfm, fillCSSVar, adjustHeadingLv, imgTag bool) (hPath, exportedMd string) {
bt := treenode.GetBlockTree(id)
if nil == bt {
return
}
addTitle := Conf.Export.AddTitle
if 1 == addTitleMode { // 0未指定遵循全局设置 Conf.Export.AddTitle1添加标题2不添加标题
addTitle = true
} else if 2 == addTitleMode {
addTitle = false
}
tree := prepareExportTree(bt)
hPath = tree.HPath
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,
Conf.Export.AddTitle, Conf.Export.InlineMemo, nil, true, fillCSSVar, map[string]*parse.Tree{})
addTitle, Conf.Export.InlineMemo, nil, true, fillCSSVar, map[string]*parse.Tree{})
docIAL := parse.IAL2Map(tree.Root.KramdownIAL)
if addYfm {
exportedMd = yfm(docIAL) + exportedMd