(text, useNativeEmoji)
| 26 | } |
| 27 | |
| 28 | export function emojify(text, useNativeEmoji) { |
| 29 | return ( |
| 30 | text |
| 31 | // Mark colons in tags |
| 32 | .replace( |
| 33 | /<(code|pre|script|template)[^>]*?>[\s\S]+?<\/(code|pre|script|template)>/g, |
| 34 | m => m.replace(/:/g, '__colon__') |
| 35 | ) |
| 36 | // Mark colons in comments |
| 37 | .replace(/<!--[\s\S]+?-->/g, m => m.replace(/:/g, '__colon__')) |
| 38 | // Mark colons in URIs |
| 39 | .replace(/([a-z]{2,}:)?\/\/[^\s'">)]+/gi, m => |
| 40 | m.replace(/:/g, '__colon__') |
| 41 | ) |
| 42 | // Replace emoji shorthand codes |
| 43 | .replace(/:([a-z0-9_\-+]+?):/g, (m, $1) => |
| 44 | replaceEmojiShorthand(m, $1, useNativeEmoji) |
| 45 | ) |
| 46 | // Restore colons in tags and comments |
| 47 | .replace(/__colon__/g, ':') |
| 48 | ); |
| 49 | } |
no test coverage detected
searching dependent graphs…