🎨 Improve exporting markdown https://github.com/siyuan-note/siyuan/issues/13500
This commit is contained in:
parent
8d1aff12e1
commit
7395554ebe
1 changed files with 11 additions and 2 deletions
|
@ -18,6 +18,7 @@ package model
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha1"
|
||||
"encoding/csv"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -3086,6 +3087,8 @@ func processFileAnnotationRef(refID string, n *ast.Node, fileAnnotationRefMode i
|
|||
|
||||
func exportPandocConvertZip(baseFolderName string, docPaths []string,
|
||||
pandocFrom, pandocTo, ext string) (zipPath string) {
|
||||
defer util.ClearPushProgress(100)
|
||||
|
||||
dir, name := path.Split(baseFolderName)
|
||||
name = util.FilterFileName(name)
|
||||
if strings.HasSuffix(name, "..") {
|
||||
|
@ -3146,8 +3149,10 @@ func exportPandocConvertZip(baseFolderName string, docPaths []string,
|
|||
docPaths = gulu.Str.RemoveDuplicatedElem(docPaths)
|
||||
}
|
||||
|
||||
wrotePathHash := map[string]string{}
|
||||
|
||||
luteEngine := util.NewLute()
|
||||
for _, p := range docPaths {
|
||||
for i, p := range docPaths {
|
||||
id := util.GetTreeID(p)
|
||||
hPath, md := exportMarkdownContent(id, exportRefMode, defBlockIDs)
|
||||
dir, name = path.Split(hPath)
|
||||
|
@ -3156,7 +3161,8 @@ func exportPandocConvertZip(baseFolderName string, docPaths []string,
|
|||
hPath = path.Join(dir, name)
|
||||
p = hPath + ext
|
||||
writePath := filepath.Join(exportFolder, p)
|
||||
if gulu.File.IsExist(writePath) {
|
||||
hash := fmt.Sprintf("%x", sha1.Sum([]byte(md)))
|
||||
if gulu.File.IsExist(writePath) && hash != wrotePathHash[writePath] {
|
||||
// 重名文档加 ID
|
||||
p = hPath + "-" + id + ext
|
||||
writePath = filepath.Join(exportFolder, p)
|
||||
|
@ -3201,6 +3207,9 @@ func exportPandocConvertZip(baseFolderName string, docPaths []string,
|
|||
logging.LogErrorf("pandoc failed: %s", err)
|
||||
continue
|
||||
}
|
||||
|
||||
wrotePathHash[writePath] = hash
|
||||
util.PushEndlessProgress(Conf.language(65) + " " + fmt.Sprintf(Conf.language(70), fmt.Sprintf("%d/%d %s", i+1, len(docPaths), name)))
|
||||
}
|
||||
|
||||
zipPath = exportFolder + ".zip"
|
||||
|
|
Loading…
Add table
Reference in a new issue