diff options
Diffstat (limited to 'modules/markup')
-rw-r--r-- | modules/markup/html.go | 7 | ||||
-rw-r--r-- | modules/markup/html_test.go | 4 |
2 files changed, 4 insertions, 7 deletions
diff --git a/modules/markup/html.go b/modules/markup/html.go index 8fbfee6a53..41248654d8 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -65,10 +65,6 @@ var ( // EmojiShortCodeRegex find emoji by alias like :smile: EmojiShortCodeRegex = regexp.MustCompile(`\:[\w\+\-]+\:{1}`) - - // find emoji literal: search all emoji hex range as many times as they appear as - // some emojis (skin color etc..) are just two or more chained together - emojiRegex = regexp.MustCompile(`[\x{1F000}-\x{1FFFF}|\x{2000}-\x{32ff}|\x{fe4e5}-\x{fe4ee}|\x{200D}|\x{FE0F}|\x{e0000}-\x{e007f}]+`) ) // CSS class for action keywords (e.g. "closes: #1") @@ -922,8 +918,7 @@ func emojiShortCodeProcessor(ctx *postProcessCtx, node *html.Node) { // emoji processor to match emoji and add emoji class func emojiProcessor(ctx *postProcessCtx, node *html.Node) { - m := emojiRegex.FindStringSubmatchIndex(node.Data) - + m := emoji.FindEmojiSubmatchIndex(node.Data) if m == nil { return } diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index 65d2d327d6..686057d11f 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -263,7 +263,9 @@ func TestRender_emoji(t *testing.T) { test( "Some text with :smile: in the middle", `<p>Some text with <span class="emoji" aria-label="grinning face with smiling eyes">😄</span> in the middle</p>`) - + test( + "Some text with 😄😄 2 emoji next to each other", + `<p>Some text with <span class="emoji" aria-label="grinning face with smiling eyes">😄</span><span class="emoji" aria-label="grinning face with smiling eyes">😄</span> 2 emoji next to each other</p>`) // should match nothing test( "2001:0db8:85a3:0000:0000:8a2e:0370:7334", |