format: accept any string-like type in SafeMarkdownCode
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run

This commit is contained in:
Tulir Asokan 2025-04-28 01:00:25 +03:00
commit a121a6101c

View file

@ -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)