diff --git a/formatter.go b/formatter.go index 679e155..8e99aa9 100644 --- a/formatter.go +++ b/formatter.go @@ -216,6 +216,14 @@ var matrixHTMLParser = &format.HTMLParser{ } return fmt.Sprintf("||%s||", text) }, + LinkConverter: func(text, href string, ctx format.Context) string { + if text == href { + return text + } else if !discordLinkRegexFull.MatchString(href) { + return fmt.Sprintf("%s (%s)", escapeDiscordMarkdown(text), escapeDiscordMarkdown(href)) + } + return fmt.Sprintf("[%s](%s)", escapeDiscordMarkdown(text), href) + }, } func (portal *Portal) parseMatrixHTML(content *event.MessageEventContent) (string, *discordgo.MessageAllowedMentions) { diff --git a/portal_convert.go b/portal_convert.go index 4192b5c..aa0d729 100644 --- a/portal_convert.go +++ b/portal_convert.go @@ -673,7 +673,7 @@ func (portal *Portal) convertDiscordTextMessage(ctx context.Context, intent *app htmlParts = append(htmlParts, fmt.Sprintf(msgInteractionTemplateHTML, puppet.MXID, puppet.Name, msg.Interaction.Name)) } if msg.Content != "" && !isPlainGifMessage(msg) { - htmlParts = append(htmlParts, portal.renderDiscordMarkdownOnlyHTML(msg.Content, false)) + htmlParts = append(htmlParts, portal.renderDiscordMarkdownOnlyHTML(msg.Content, true)) } previews := make([]*BeeperLinkPreview, 0) for i, embed := range msg.Embeds {