@@ -901,38 +901,54 @@ func fullSha1PatternProcessor(ctx *RenderContext, node *html.Node) {
901
901
902
902
// emojiShortCodeProcessor for rendering text like :smile: into emoji
903
903
func emojiShortCodeProcessor (ctx * RenderContext , node * html.Node ) {
904
- m := EmojiShortCodeRegex .FindStringSubmatchIndex (node .Data )
905
- if m == nil {
906
- return
907
- }
908
-
909
- alias := node .Data [m [0 ]:m [1 ]]
910
- alias = strings .ReplaceAll (alias , ":" , "" )
911
- converted := emoji .FromAlias (alias )
912
- if converted == nil {
913
- // check if this is a custom reaction
914
- s := strings .Join (setting .UI .Reactions , " " ) + "gitea"
915
- if strings .Contains (s , alias ) {
916
- replaceContent (node , m [0 ], m [1 ], createCustomEmoji (alias , "emoji" ))
904
+ start := 0
905
+ for node != nil && start < len (node .Data ) {
906
+ m := EmojiShortCodeRegex .FindStringSubmatchIndex (node .Data )
907
+ if m == nil {
917
908
return
918
909
}
919
- return
920
- }
921
910
922
- replaceContent (node , m [0 ], m [1 ], createEmoji (converted .Emoji , "emoji" , converted .Description ))
911
+ start = m [1 ]
912
+
913
+ alias := node .Data [m [0 ]:m [1 ]]
914
+ alias = strings .ReplaceAll (alias , ":" , "" )
915
+ converted := emoji .FromAlias (alias )
916
+ if converted == nil {
917
+ // check if this is a custom reaction
918
+ s := strings .Join (setting .UI .Reactions , " " ) + "gitea"
919
+ if strings .Contains (s , alias ) {
920
+ replaceContent (node , m [0 ], m [1 ], createCustomEmoji (alias , "emoji" ))
921
+ node = node .NextSibling .NextSibling
922
+ start = 0
923
+ continue
924
+ }
925
+ continue
926
+ }
927
+
928
+ replaceContent (node , m [0 ], m [1 ], createEmoji (converted .Emoji , "emoji" , converted .Description ))
929
+ node = node .NextSibling .NextSibling
930
+ start = 0
931
+ }
923
932
}
924
933
925
934
// emoji processor to match emoji and add emoji class
926
935
func emojiProcessor (ctx * RenderContext , node * html.Node ) {
927
- m := emoji .FindEmojiSubmatchIndex (node .Data )
928
- if m == nil {
929
- return
930
- }
936
+ start := 0
937
+ for node != nil && start < len (node .Data ) {
938
+ m := emoji .FindEmojiSubmatchIndex (node .Data [start :])
939
+ if m == nil {
940
+ return
941
+ }
931
942
932
- codepoint := node .Data [m [0 ]:m [1 ]]
933
- val := emoji .FromCode (codepoint )
934
- if val != nil {
935
- replaceContent (node , m [0 ], m [1 ], createEmoji (codepoint , "emoji" , val .Description ))
943
+ start = m [1 ]
944
+
945
+ codepoint := node .Data [m [0 ]:m [1 ]]
946
+ val := emoji .FromCode (codepoint )
947
+ if val != nil {
948
+ replaceContent (node , m [0 ], m [1 ], createEmoji (codepoint , "emoji" , val .Description ))
949
+ node = node .NextSibling .NextSibling
950
+ start = 0
951
+ }
936
952
}
937
953
}
938
954
0 commit comments