From 591d612a5b966a65a43b2bee5823a891e50553e2 Mon Sep 17 00:00:00 2001 From: Haw Loeung Date: Sat, 12 Nov 2022 14:31:43 +1100 Subject: [PATCH] Add support for syntax highlighted code blocks --- mm-go-irckit/userbridge.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm-go-irckit/userbridge.go b/mm-go-irckit/userbridge.go index 1079eded..b71cd7d6 100644 --- a/mm-go-irckit/userbridge.go +++ b/mm-go-irckit/userbridge.go @@ -143,7 +143,7 @@ func (u *User) handleDirectMessageEvent(event *bridge.DirectMessageEvent) { text = wordwrap.String(text, maxlen) lines := strings.Split(text, "\n") for _, text := range lines { - if text == "```" { + if strings.HasPrefix(text, "```") { codeBlock = !codeBlock } // skip empty lines for anything not part of a code block. @@ -287,7 +287,7 @@ func (u *User) handleChannelMessageEvent(event *bridge.ChannelMessageEvent) { text = wordwrap.String(text, maxlen) lines := strings.Split(text, "\n") for _, text := range lines { - if text == "```" { + if strings.HasPrefix(text, "```") { codeBlock = !codeBlock } // skip empty lines for anything not part of a code block.