mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-02 06:48:49 +01:00
🎨 Attribute View columns calculate https://github.com/siyuan-note/siyuan/issues/8699
This commit is contained in:
parent
ae1cddf98e
commit
6f57787fcf
1 changed files with 5 additions and 2 deletions
|
|
@ -24,6 +24,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/ast"
|
||||
|
|
@ -148,7 +149,8 @@ func NewFormattedValueNumber(content float64, format NumberFormat) (ret *ValueNu
|
|||
case NumberFormatNone:
|
||||
ret.FormattedContent = strconv.FormatFloat(content, 'f', -1, 64)
|
||||
case NumberFormatPercent:
|
||||
ret.FormattedContent = strconv.FormatFloat(content*100, 'f', -1, 64) + "%"
|
||||
s := fmt.Sprintf("%.2f", content*100)
|
||||
ret.FormattedContent = strings.TrimRight(strings.TrimRight(s, "0"), ".") + "%"
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -158,7 +160,8 @@ func (number *ValueNumber) FormatNumber() {
|
|||
case NumberFormatNone:
|
||||
number.FormattedContent = strconv.FormatFloat(number.Content, 'f', -1, 64)
|
||||
case NumberFormatPercent:
|
||||
number.FormattedContent = strconv.FormatFloat(number.Content*100, 'f', -1, 64) + "%"
|
||||
s := fmt.Sprintf("%.2f", number.Content*100)
|
||||
number.FormattedContent = strings.TrimRight(strings.TrimRight(s, "0"), ".") + "%"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue