feat: 添加markdown保存到文件的方法和程序入口

This commit is contained in:
fengxxc
2021-12-02 19:30:33 +08:00
parent bf54eb7fc5
commit 2c52c00f82
2 changed files with 23 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
package format
import (
"io/ioutil"
"strconv"
"github.com/fengxxc/wechatmp2markdown/parse"
@@ -19,6 +20,11 @@ func Format(article parse.Article) string {
return result
}
func FormatAndSave(article parse.Article, filePath string) {
var result string = Format(article)
ioutil.WriteFile(filePath, []byte(result), 0644)
}
func formatTitle(piece parse.Piece) string {
var prefix string
level, _ := strconv.Atoi(piece.Attrs["level"])