We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
user-content-*
1 parent 06aae9a commit 7b79294Copy full SHA for 7b79294
modules/markup/common/footnote.go
@@ -29,12 +29,17 @@ func CleanValue(value []byte) []byte {
29
value = bytes.TrimSpace(value)
30
rs := bytes.Runes(value)
31
result := make([]rune, 0, len(rs))
32
+ needsDash := false
33
for _, r := range rs {
- if unicode.IsLetter(r) || unicode.IsNumber(r) || r == '_' || r == '-' {
34
+ switch {
35
+ case unicode.IsLetter(r) || unicode.IsNumber(r) || r == '_':
36
+ if needsDash && len(result) > 0 {
37
+ result = append(result, '-')
38
+ }
39
+ needsDash = false
40
result = append(result, unicode.ToLower(r))
- }
- if unicode.IsSpace(r) {
- result = append(result, '-')
41
+ default:
42
+ needsDash = true
43
}
44
45
return []byte(string(result))
modules/markup/common/footnote_test.go
0 commit comments