2020-05-03 18:00:50 +02:00
|
|
|
package txt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Quote adds quotation marks to a string if needed.
|
|
|
|
func Quote(text string) string {
|
2021-08-22 16:14:34 +02:00
|
|
|
if text == "" || strings.ContainsAny(text, " \n'\"") {
|
2020-05-03 18:00:50 +02:00
|
|
|
return fmt.Sprintf("“%s”", text)
|
|
|
|
}
|
|
|
|
|
|
|
|
return text
|
|
|
|
}
|
2021-09-23 23:46:17 +02:00
|
|
|
|
|
|
|
// QuoteLower converts a string to lowercase and adds quotation marks if needed.
|
|
|
|
func QuoteLower(text string) string {
|
|
|
|
return Quote(strings.ToLower(text))
|
|
|
|
}
|