diff --git a/format/markdown.go b/format/markdown.go index 59248c72..f6181ed9 100644 --- a/format/markdown.go +++ b/format/markdown.go @@ -50,8 +50,8 @@ func EscapeMarkdown(text string) string { return text } -func SafeMarkdownCode(text string) string { - text = strings.ReplaceAll(text, "\n", " ") +func SafeMarkdownCode[T ~string](textInput T) string { + text := strings.ReplaceAll(string(textInput), "\n", " ") backtickCount := exstrings.LongestSequenceOf(text, '`') if backtickCount == 0 { return fmt.Sprintf("`%s`", text)