fix there are unnecessary separators in exported file when the tag in transaction does not exist, fix the incorrect exported data when the content contains CR("\r")

This commit is contained in:
MaysWind
2024-09-03 00:47:47 +08:00
parent 1d43eda9b7
commit 2dddb77ca4
2 changed files with 119 additions and 5 deletions
+6 -5
View File
@@ -441,10 +441,6 @@ func (e *EzBookKeepingPlainFileConverter) getTags(transactionId int64, allTagInd
var ret strings.Builder
for i := 0; i < len(tagIndexes); i++ {
if i > 0 {
ret.WriteString(transactionTagSeparator)
}
tagIndex := tagIndexes[i]
tag, exists := tagMap[tagIndex]
@@ -452,7 +448,11 @@ func (e *EzBookKeepingPlainFileConverter) getTags(transactionId int64, allTagInd
continue
}
ret.WriteString(tag.Name)
if ret.Len() > 0 {
ret.WriteString(transactionTagSeparator)
}
ret.WriteString(strings.Replace(tag.Name, transactionTagSeparator, " ", -1))
}
return ret.String()
@@ -461,6 +461,7 @@ func (e *EzBookKeepingPlainFileConverter) getTags(transactionId int64, allTagInd
func (e *EzBookKeepingPlainFileConverter) replaceDelimiters(text string, separator string) string {
text = strings.Replace(text, separator, " ", -1)
text = strings.Replace(text, "\r\n", " ", -1)
text = strings.Replace(text, "\r", " ", -1)
text = strings.Replace(text, "\n", " ", -1)
return text