diff options
Diffstat (limited to 'modules/markup/common/footnote.go')
-rw-r--r-- | modules/markup/common/footnote.go | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/modules/markup/common/footnote.go b/modules/markup/common/footnote.go index 0e75e2adfd..4406803694 100644 --- a/modules/markup/common/footnote.go +++ b/modules/markup/common/footnote.go @@ -29,17 +29,12 @@ func CleanValue(value []byte) []byte { value = bytes.TrimSpace(value) rs := bytes.Runes(value) result := make([]rune, 0, len(rs)) - needsDash := false for _, r := range rs { - switch { - case unicode.IsLetter(r) || unicode.IsNumber(r) || r == '_': - if needsDash && len(result) > 0 { - result = append(result, '-') - } - needsDash = false + if unicode.IsLetter(r) || unicode.IsNumber(r) || r == '_' || r == '-' { result = append(result, unicode.ToLower(r)) - default: - needsDash = true + } + if unicode.IsSpace(r) { + result = append(result, '-') } } return []byte(string(result)) |