updated deps

This commit is contained in:
Aine
2023-02-13 13:02:13 +02:00
parent dbe4a73174
commit 19e2047a2b
140 changed files with 4106 additions and 12049 deletions

View File

@@ -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 = "* "