File tree 4 files changed +16
-3
lines changed
4 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 5
5
exclude github.com/stretchr/testify v1.7.1
6
6
7
7
require github.com/stretchr/testify v1.8.1
8
+
9
+ retract [v1.0.0 , v1.0.1 ]
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ func Test_Humanize(t *testing.T) {
20
20
{"first_name" , "First name" },
21
21
{"first_Name" , "First Name" },
22
22
{"firstName" , "First Name" },
23
+ {"óbito" , "Óbito" },
23
24
}
24
25
25
26
for _ , tt := range table {
Original file line number Diff line number Diff line change @@ -19,12 +19,20 @@ func Titleize(s string) string {
19
19
// "This is `code` ok" = "This Is `code` OK"
20
20
func (i Ident ) Titleize () Ident {
21
21
var parts []string
22
+
23
+ // TODO: we need to reconsider the design.
24
+ // this approach preserves inline code block as is but it also
25
+ // preserves the other words start with a special character.
26
+ // I would prefer: "*wonderful* world" to be "*Wonderful* World"
22
27
for _ , part := range i .Parts {
23
- x := string (unicode .ToTitle (rune (part [0 ])))
24
- if len (part ) > 1 {
25
- x += part [1 :]
28
+ // CAUTION: in unicode, []rune(str)[0] is not rune(str[0])
29
+ runes := []rune (part )
30
+ x := string (unicode .ToTitle (runes [0 ]))
31
+ if len (runes ) > 1 {
32
+ x += string (runes [1 :])
26
33
}
27
34
parts = append (parts , x )
28
35
}
36
+
29
37
return New (strings .Join (parts , " " ))
30
38
}
Original file line number Diff line number Diff line change @@ -12,11 +12,13 @@ func Test_Titleize(t *testing.T) {
12
12
{"bob dylan" , "Bob Dylan" },
13
13
{"Nice to see you!" , "Nice To See You!" },
14
14
{"*hello*" , "*hello*" },
15
+ {"hello *wonderful* world!" , "Hello *wonderful* World!" }, // CHKME
15
16
{"i've read a book! have you?" , "I've Read A Book! Have You?" },
16
17
{"This is `code` ok" , "This Is `code` OK" },
17
18
{"foo_bar" , "Foo Bar" },
18
19
{"admin/widget" , "Admin Widget" },
19
20
{"widget" , "Widget" },
21
+ {"óbito" , "Óbito" },
20
22
}
21
23
22
24
for _ , tt := range table {
You can’t perform that action at this time.
0 commit comments