Skip to content

Commit 4906ae0

Browse files
committed
Fixed to use best practices for middle of word emphasis
Per https://www.markdownguide.org/basic-syntax#emphasis
1 parent 16cc1ce commit 4906ae0

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

mm-go-irckit/userbridge.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,21 +1188,24 @@ func (u *User) formatCodeBlockText(text string, prefix string, codeBlockBackTick
11881188
// Bold & Italic - https://www.markdownguide.org/basic-syntax#bold-and-italic
11891189
var boldItalicRegExp = []*regexp.Regexp{
11901190
regexp.MustCompile(`(?:\*\*\*)+?(.+?)(?:\*\*\*)+?`),
1191-
regexp.MustCompile(`(?:\_\_\_)+?(.+?)(?:\_\_\_)+?`),
1192-
regexp.MustCompile(`(?:\_\_\*)+?(.+?)(?:\*\_\_)+?`),
1193-
regexp.MustCompile(`(?:\*\*\_)+?(.+?)(?:\_\*\*)+?`),
1191+
regexp.MustCompile(`\b(?:\_\_\_)+?(.+?)(?:\_\_\_)+?\b`),
1192+
regexp.MustCompile(`\b(?:\_\_\*)+?(.+?)(?:\*\_\_)+?\b`),
1193+
regexp.MustCompile(`\b(?:\*\*\_)+?(.+?)(?:\_\*\*)+?\b`),
11941194
}
11951195

11961196
// Bold - https://www.markdownguide.org/basic-syntax#bold
11971197
var boldRegExp = []*regexp.Regexp{
11981198
regexp.MustCompile(`(?:\*\*)+?(.+?)(?:\*\*)+?`),
1199-
regexp.MustCompile(`(?:\_\_)+?(.+?)(?:\_\_)+?`),
1199+
regexp.MustCompile(`\b(?:\_\_)+?(.+?)(?:\_\_)+?\b`),
1200+
}
1201+
var boldRegExp2 = []*regexp.Regexp{
1202+
regexp.MustCompile(`(?:\*\*)+?(.+?)(?:\*\*)+?`),
12001203
}
12011204

12021205
// Italic - https://www.markdownguide.org/basic-syntax#italic
12031206
var italicRegExp = []*regexp.Regexp{
1204-
regexp.MustCompile(`(?:\*)+?(.+?)(?:\*)+?`),
1205-
regexp.MustCompile(`(?:\_)+?(.+?)(?:\_)+?`),
1207+
regexp.MustCompile(`(?:\*)+?([^\*]+?)(?:\*)+?`),
1208+
regexp.MustCompile(`\b(?:\_)+?([^_]+?)(?:\_)+?\b`),
12061209
}
12071210

12081211
func markdown2irc(msg string) string {

0 commit comments

Comments
 (0)