From 98a3eadd595fd4a1d9ca7660d7f866e4868b5624 Mon Sep 17 00:00:00 2001 From: Haw Loeung Date: Sun, 17 Sep 2023 19:57:11 +1000 Subject: [PATCH] Fixed to use best practices for middle of word emphasis Per https://www.markdownguide.org/basic-syntax#emphasis --- mm-go-irckit/userbridge.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm-go-irckit/userbridge.go b/mm-go-irckit/userbridge.go index 5f354a02..3e51ca6d 100644 --- a/mm-go-irckit/userbridge.go +++ b/mm-go-irckit/userbridge.go @@ -1188,21 +1188,21 @@ func (u *User) formatCodeBlockText(text string, prefix string, codeBlockBackTick // Bold & Italic - https://www.markdownguide.org/basic-syntax#bold-and-italic var boldItalicRegExp = []*regexp.Regexp{ regexp.MustCompile(`(?:\*\*\*)+?(.+?)(?:\*\*\*)+?`), - regexp.MustCompile(`(?:\_\_\_)+?(.+?)(?:\_\_\_)+?`), - regexp.MustCompile(`(?:\_\_\*)+?(.+?)(?:\*\_\_)+?`), - regexp.MustCompile(`(?:\*\*\_)+?(.+?)(?:\_\*\*)+?`), + regexp.MustCompile(`\b(?:\_\_\_)+?(.+?)(?:\_\_\_)+?\b`), + regexp.MustCompile(`\b(?:\_\_\*)+?(.+?)(?:\*\_\_)+?\b`), + regexp.MustCompile(`\b(?:\*\*\_)+?(.+?)(?:\_\*\*)+?\b`), } // Bold - https://www.markdownguide.org/basic-syntax#bold var boldRegExp = []*regexp.Regexp{ regexp.MustCompile(`(?:\*\*)+?(.+?)(?:\*\*)+?`), - regexp.MustCompile(`(?:\_\_)+?(.+?)(?:\_\_)+?`), + regexp.MustCompile(`\b(?:\_\_)+?(.+?)(?:\_\_)+?\b`), } // Italic - https://www.markdownguide.org/basic-syntax#italic var italicRegExp = []*regexp.Regexp{ - regexp.MustCompile(`(?:\*)+?(.+?)(?:\*)+?`), - regexp.MustCompile(`(?:\_)+?(.+?)(?:\_)+?`), + regexp.MustCompile(`(?:\*)+?([^\*]+?)(?:\*)+?`), + regexp.MustCompile(`\b(?:\_)+?([^_]+?)(?:\_)+?\b`), } func markdown2irc(msg string) string {