updated deps
This commit is contained in:
11
vendor/maunium.net/go/mautrix/format/htmlparser.go
generated
vendored
11
vendor/maunium.net/go/mautrix/format/htmlparser.go
generated
vendored
@@ -83,8 +83,13 @@ func (parser *HTMLParser) getAttribute(node *html.Node, attribute string) string
|
||||
return val
|
||||
}
|
||||
|
||||
// Digits counts the number of digits in a non-negative integer.
|
||||
// Digits counts the number of digits (and the sign, if negative) in an integer.
|
||||
func Digits(num int) int {
|
||||
if num == 0 {
|
||||
return 1
|
||||
} else if num < 0 {
|
||||
return Digits(-num) + 1
|
||||
}
|
||||
return int(math.Floor(math.Log10(float64(num))) + 1)
|
||||
}
|
||||
|
||||
@@ -112,6 +117,10 @@ func (parser *HTMLParser) listToString(node *html.Node, stripLinebreak bool, ctx
|
||||
// TODO make bullets and numbering configurable
|
||||
if ordered {
|
||||
indexPadding := indentLength - Digits(counter)
|
||||
if indexPadding < 0 {
|
||||
// This will happen on negative start indexes where longestIndex is usually wrong, otherwise shouldn't happen
|
||||
indexPadding = 0
|
||||
}
|
||||
prefix = fmt.Sprintf("%d. %s", counter, strings.Repeat(" ", indexPadding))
|
||||
} else {
|
||||
prefix = "* "
|
||||
|
||||
Reference in New Issue
Block a user