feat: 对文章Meta信息的支持

This commit is contained in:
fengxxc
2022-10-17 17:32:45 +08:00
parent aba651ed21
commit ab9b5c2d07
3 changed files with 41 additions and 23 deletions

View File

@@ -3,6 +3,7 @@ package format
import (
"io/ioutil"
"strconv"
"strings"
"github.com/fengxxc/wechatmp2markdown/parse"
)
@@ -20,9 +21,9 @@ func Format(article parse.Article) string {
return result
}
func FormatAndSave(article parse.Article, filePath string) {
func FormatAndSave(article parse.Article, filePath string) error {
var result string = Format(article)
ioutil.WriteFile(filePath, []byte(result), 0644)
return ioutil.WriteFile(filePath, []byte(result), 0644)
}
func formatTitle(piece parse.Piece) string {
@@ -34,8 +35,8 @@ func formatTitle(piece parse.Piece) string {
return prefix + " " + piece.Val.(string) + " \n"
}
func formatMeta(meta string) string {
return meta + " \n" // TODO
func formatMeta(meta []string) string {
return strings.Join(meta, " ") + " \n" // TODO
}
func formatTags(tags string) string {