mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
format: accept any string-like type in SafeMarkdownCode
This commit is contained in:
parent
287899435d
commit
a121a6101c
1 changed files with 2 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue