diff options
author | Nick White <git@njw.name> | 2021-05-10 16:13:31 +0100 |
---|---|---|
committer | Nick White <git@njw.name> | 2021-05-10 16:13:31 +0100 |
commit | 9f306c8808040e826e6ef008626398e5cb925a3a (patch) | |
tree | e8ac682d0cd1d264095e98856211a83ab14022c6 /cmd/dlgbook | |
parent | bfcb4f8b6f9805347e7ed45181c7fe38fe90a444 (diff) |
dlgbook: Strip special characters from authors as well as titles
Diffstat (limited to 'cmd/dlgbook')
-rw-r--r-- | cmd/dlgbook/main.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/cmd/dlgbook/main.go b/cmd/dlgbook/main.go index c771f1e..fffa3f4 100644 --- a/cmd/dlgbook/main.go +++ b/cmd/dlgbook/main.go @@ -45,12 +45,14 @@ func formatAuthors(authors []string) string { s = s[:maxPartLength] } + s = strings.Map(stripNonLetters, s) + return s } // mapTitle is a function for strings.Map to strip out // unwanted characters from the title. -func mapTitle(r rune) rune { +func stripNonLetters(r rune) rune { if !unicode.IsLetter(r) { return -1 } @@ -60,7 +62,7 @@ func mapTitle(r rune) rune { // formatTitle formats a title to our preferences, notably // by stripping spaces and punctuation characters. func formatTitle(title string) string { - s := strings.Map(mapTitle, title) + s := strings.Map(stripNonLetters, title) if len(s) > maxPartLength { s = s[:maxPartLength] } |