Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2024-04-26 22:20:36 +08:00
commit 0f54c36205
5 changed files with 23 additions and 7 deletions

File diff suppressed because one or more lines are too long

View file

@ -10,7 +10,7 @@ require (
github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48
github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7
github.com/88250/gulu v1.2.3-0.20240324024901-3c1bb82cba30
github.com/88250/lute v1.7.7-0.20240426110724-af196e65f72e
github.com/88250/lute v1.7.7-0.20240426133648-3786f77d8e74
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4

View file

@ -12,8 +12,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceT
github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/88250/gulu v1.2.3-0.20240324024901-3c1bb82cba30 h1:IeE4DVRWnVpcbMj7gGZoSMiBWs3h/ihiyOmualS1Mas=
github.com/88250/gulu v1.2.3-0.20240324024901-3c1bb82cba30/go.mod h1:MUfzyfmbPrRDZLqxc7aPrVYveatTHRfoUa5TynPS0i8=
github.com/88250/lute v1.7.7-0.20240426110724-af196e65f72e h1:wJGOt4+WF+oif89/KyA/vs2qkbsvGKHN5VA52dEbQv8=
github.com/88250/lute v1.7.7-0.20240426110724-af196e65f72e/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
github.com/88250/lute v1.7.7-0.20240426133648-3786f77d8e74 h1:Gdm5U4cyrw4bJMM5qAjAqI6A6F8quTyFOHzxNbwpWlw=
github.com/88250/lute v1.7.7-0.20240426133648-3786f77d8e74/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c h1:Dl/8S9iLyPMTElnWIBxmjaLiWrkI5P4a21ivwAn5pU0=
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=

View file

@ -120,6 +120,15 @@ func RemoveRedundantSpace(str string) string {
func Convert2Float(s string) (float64, bool) {
s = gulu.Str.RemoveInvisible(s)
s = strings.ReplaceAll(s, " ", "")
s = strings.ReplaceAll(s, ",", "")
buf := bytes.Buffer{}
for _, r := range s {
if unicode.IsDigit(r) || '.' == r {
buf.WriteRune(r)
}
}
s = buf.String()
ret, err := strconv.ParseFloat(strings.TrimSpace(s), 64)
if nil != err {
return 0, false

View file

@ -17,13 +17,15 @@
package util
import (
"math"
"text/template"
"time"
"github.com/88250/go-humanize"
"github.com/Masterminds/sprig/v3"
"github.com/araddon/dateparse"
"github.com/siyuan-note/logging"
"github.com/spf13/cast"
"math"
"text/template"
"time"
)
func BuiltInTemplateFuncs() (ret template.FuncMap) {
@ -37,6 +39,7 @@ func BuiltInTemplateFuncs() (ret template.FuncMap) {
ret["log"] = log
ret["logf"] = logf
ret["parseTime"] = parseTime
ret["FormatFloat"] = FormatFloat
return
}
@ -56,3 +59,7 @@ func parseTime(dateStr string) time.Time {
}
return retTime
}
func FormatFloat(format string, n float64) string {
return humanize.FormatFloat(format, n)
}