From 9f306c8808040e826e6ef008626398e5cb925a3a Mon Sep 17 00:00:00 2001 From: Nick White Date: Mon, 10 May 2021 16:13:31 +0100 Subject: dlgbook: Strip special characters from authors as well as titles --- cmd/dlgbook/main.go | 6 ++++-- 1 file 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] } -- cgit v1.2.1-24-ge1ad