### Setup Development Environment Source: https://github.com/twitter/twemoji/blob/master/CONTRIBUTING.md Clone the repository, install dependencies, and build the project to set up your local development environment. ```bash git clone -b master https://github.com/$YOUR_USERNAME/twemoji.git/ cd twemoji yarn install yarn build yarn test ``` -------------------------------- ### Twemoji Parse with Folder and Extension Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Example of using the 'folder' and 'ext' options to generate URLs for SVG emoji. This replaces the default size-based URL generation. ```javascript twemoji.parse(genericNode, { folder: 'svg', ext: '.svg' }); ``` -------------------------------- ### DOM Parsing Example Source: https://github.com/twitter/twemoji/blob/master/README.md Demonstrates how to use `twemoji.parse()` with a DOM element. This method replaces emoji within text nodes, preserving surrounding HTML and event listeners. It's a safe option for replacing emoji directly in the document. ```js var div = document.createElement('div'); div.textContent = 'I emoji!'; document.body.appendChild(div); twemoji.parse(document.body); var img = div.querySelector('img'); // note the div is preserved img.parentNode === div; // true img.src; // https://twemoji.maxcdn.com/v/latest/72x72/2764.png img.alt; // img.className; // emoji img.draggable; // false ``` -------------------------------- ### twemoji Test Runner Initialization Source: https://github.com/twitter/twemoji/blob/master/src/test/index.html Initializes the twemoji test runner framework. This code sets up global variables and functions for managing tests, assertions, and reporting. It also includes a timer for visual feedback during asynchronous operations. ```javascript /*\n *! (C) Andrea Giammarchi, @WebReflection - Mit Style License \n */ (function(wru){ window.wru = wru; }(function(Y){function j(){A=K.call(m);if(A){if(typeof A=="function"){A={name:A\[S\]||"anonymous",test:A}}(P=l(l(Z.node,"div"),"span"))\[E\]=((ag(A,S)&&A\[S\])||(ag(A,e)&&A\[e\])||Q)+i+i;a=\[\];u=\[\];T=\[\];ab={};b("setup");T\[ah\]||b("test");N||r()}else{t()}}function p(aj){try{return O.call(h,aj)}catch(ai){return h.createElement(aj)}}function l(ai,aj){return ai.appendChild(p(aj))}function g(ai){P\[E\]=x.call(P\[E\],0,-2)+i+ai}function t(){var ak=Z.node.insertBefore(p("div"),Z.node.firstChild),al,aj,ai;if(ad){ai=aj="error";al="There Are Errors: "+ad}else{if(C){ai=aj="fail";al=C+" Tests Failed"}else{ai=aj="pass";al="Passed "+s+" Tests"}}Z.status=ai;ak\[E\]=""+al+"";ak.className=aj}function G(){var ai=this.lastChild.style;ai.display=ai.display=="none"?"block":"none"}function c(ai){P\[E\]+="";(P.onclick=G).call(P)}function r(){f();s+=a\[ah\];C+=u\[ah\];ad+=T\[ah\];g("("+v.call(\[a\[ah\],M=u\[ah\],T\[ah\]\],", ")+")");P=P.parentNode;T\[ah\]?c(T,W="error"):(M?c(u,W="fail"):W="pass");P.className=W;M=0;W=i;j()}function b(ai){if(ag(A,ai)){try{A\[ai\](ab)}catch(aj){aa.call(T,i+aj)}}}function ag(aj,ai){return q.call(aj,ai)}function w(){return F()<0.5?-1:1}function f(){if(R){H(R);R=0}b("teardown")}var Z={assert:function U(aj,ai){if(arguments\[ah\]==1){ai=aj;aj=Q}z=I;aa.call(ai?a:u,W+aj);return ai},async:function V(aj,am,ak,al){al=++N;if(typeof aj=="function"){ak=am;am=aj;aj="asynchronous test #"+al}ak=X(function(){al=0;aa.call(u,aj);--N||(R=X(r,0))},L(ak||y)||y);return function ai(){if(!al){return}z=ae;W=aj+": ";try{am.apply(this,arguments)}catch(an){z=I;aa.call(T,W+an)}W=i;if(z){H(ak);--N||(R=X(r,0))}}},test:function n(ai,aj){Z.after=aj||function(){};m=J.apply(m,\\[ai\\]);Z.random&&af.call(m,w);N||j()}},I:true,ae:!I,y:100,i:" ",Q:"unknown",ah:"length",S:"name",e:"description",D:"
  • ",d:"
  • ",k:"\\|/-",q:Z.hasOwnProperty,W:i,ac:W.charAt,x:W.slice,m:[],J:m.concat,v:m.join,aa:m.push,K:m.shift,af:m.sort,N:0,M:0,s:0,C:0,ad:0,R:0,E:"innerHTML",h:Y.document,O:h.createElement,B,L,F,X,H,A,P,a,u,T,ab,z;B=Y.Math;L=B.abs;F=B.random;X=Y.setTimeout;H=Y.clearTimeout;Z.node=(h.getElementById("wru")||h.body||h.documentElement);Y.setInterval(function(){N&&g(ac.call(k,M++%4))},y);undefined;Z.log=function o(aj,ai){ai?alert(aj):(typeof console!="undefined")&&console.log(aj)};y\*=y;Z.random=ae;return Z}(this))); ``` -------------------------------- ### Include Twemoji via CDN (Latest Version) Source: https://github.com/twitter/twemoji/blob/master/README.md Use this script tag in your HTML's to always include the latest version of the Twemoji library from the CDN. ```html ``` -------------------------------- ### twemoji.parse() Options Object Source: https://github.com/twitter/twemoji/blob/master/README.md Lists the properties that can be passed in an options object to `twemoji.parse()`. These options allow customization of the generated image URLs, including the callback, base URL, file extension, class name, size, and folder. ```js { callback: Function, // default the common replacer attributes: Function, // default returns {} base: string, // default MaxCDN ext: string, // default ".png" className: string, // default "emoji" size: string|number, // default "72x72" folder: string // in case it's specified // it replaces .size info, if any } ``` -------------------------------- ### Include Twemoji V1 via CDN Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Use this script tag in your HTML's `` to include the V1 Twemoji library from a CDN. ```html ``` -------------------------------- ### String Parsing with Options Object Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Pass an object as the second parameter to configure parsing options, such as custom callbacks and image sizes. ```javascript twemoji.parse( 'I emoji!', { callback: function(icon, options) { return '/assets/' + options.size + '/' + icon + '.gif'; }, size: 128 } ); // will produce /* I ❤️ emoji! */ ``` -------------------------------- ### twemoji.convert.toCodePoint() Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Converts UTF-16 surrogate pairs into their equivalent HEX codepoint. ```APIDOC ## twemoji.convert.toCodePoint() ### Description For given UTF-16 surrogate pairs, returns the equivalent HEX codepoint. ### Parameters #### Path Parameters - **surrogatePairs** (string) - Required - The UTF-16 surrogate pairs to convert. - **separator** (string) - Optional - A separator to use between codepoints if multiple are provided. ### Request Example ```javascript twemoji.convert.toCodePoint('\ud83c\udde8\ud83c\uddf3'); twemoji.convert.toCodePoint('\ud83c\udde8\ud83c\uddf3', '~'); ``` ### Response #### Success Response (string) - **codepoint** (string) - The equivalent HEX codepoint(s). ### Response Example ```json "1f1e8-1f1f3" "1f1e8~1f1f3" ``` ``` -------------------------------- ### twemoji.parse() - String Parsing with Options Object Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Parses a string and allows customization through an options object, which can include a callback function and size parameters. ```APIDOC ## twemoji.parse(string, options) ### Description Parses a string and applies options for customization. The options object can contain a `callback` function and a `size` property to control the generated `` tags. ### Method `twemoji.parse(text: string, options: { callback?: function(icon: string, options: object): string, size?: number | string }): string` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript twemoji.parse( 'I \u2764\uFE0F emoji!', { callback: function(icon, options) { return '/assets/' + options.size + '/' + icon + '.gif'; }, size: 128 } ); ``` ### Response #### Success Response (string) Returns the string with emoji replaced by `` tags, with attributes customized by the provided options. #### Response Example ```html I ❤️ emoji! ``` ``` -------------------------------- ### twemoji.convert.fromCodePoint() Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Converts a given HEX codepoint into its corresponding UTF-16 surrogate pairs. ```APIDOC ## twemoji.convert.fromCodePoint() ### Description For a given HEX codepoint, returns UTF-16 surrogate pairs. ### Parameters #### Path Parameters - **codepoint** (string) - Required - The HEX codepoint to convert. ### Request Example ```javascript twemoji.convert.fromCodePoint('1f1e8'); ``` ### Response #### Success Response (string) - **surrogatePairs** (string) - The UTF-16 surrogate pairs. ### Response Example ```json "\ud83c\udde8" ``` ``` -------------------------------- ### twemoji.parse() - String Parsing with Callback Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Parses a string and uses a callback function to determine the `src` attribute for the generated `` tags. The callback receives the icon identifier, options, and variant. ```APIDOC ## twemoji.parse(string, callback) ### Description Parses a string, and for each emoji, calls a callback function to generate the `src` attribute for the `` tag. If the callback returns a falsy value, the emoji remains unchanged. ### Method `twemoji.parse(text: string, callback: function(icon: string, options: object, variant: string): string | null | undefined | false | 0): string` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript twemoji.parse( 'I \u2764\uFE0F emoji!', function(icon, options, variant) { return '/assets/' + options.size + '/' + icon + '.gif'; } ); ``` ### Response #### Success Response (string) Returns the string with emoji replaced by `` tags, with `src` attributes determined by the callback. #### Response Example ```html I ❤️ emoji! ``` ``` -------------------------------- ### Include Twemoji via CDN (Explicit Version) Source: https://github.com/twitter/twemoji/blob/master/README.md Include a specific version of the Twemoji library by using this script tag, which points to version 14.0.3. ```html ``` -------------------------------- ### String Parsing with Custom Callback Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Allows custom image source generation for emoji by providing a callback function. The callback receives icon, options, and variant. ```javascript twemoji.parse( 'I emoji!', function(icon, options, variant) { return '/assets/' + options.size + '/' + icon + '.gif'; } ); // will produce /* I ❤️ emoji! */ ``` -------------------------------- ### Custom Image Source Generator Function Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md The callback function to invoke to generate image src attributes. It receives the icon code point and options, and should return a formatted URL string. ```javascript function imageSourceGenerator(icon, options) { return ''.concat( options.base, // by default Twitter Inc. CDN options.size, // by default "36x36" string '/', icon, // the found emoji as code point options.ext // by default ".png" ); } ``` -------------------------------- ### Default Image Source Generator Callback Source: https://github.com/twitter/twemoji/blob/master/README.md Shows the default function used by `twemoji.parse()` to generate the `src` attribute for emoji images. It constructs the URL using the provided options like base CDN, size, icon code point, and extension. ```js function imageSourceGenerator(icon, options) { return ''.concat( options.base, // by default Twitter Inc. CDN options.size, // by default "72x72" string '/', icon, // the found emoji as code point options.ext // by default ".png" ); } ``` -------------------------------- ### Parse Body Content with Twemoji Source: https://github.com/twitter/twemoji/blob/master/src/test/base.html This snippet demonstrates how to parse the entire document body for emojis and render them using Twemoji. It's typically used after the page has loaded. ```javascript this.onload = function () { twemoji.parse(document.body, { folder: 'svg', ext: '.svg' }); }; ``` -------------------------------- ### Twemoji Parse Options Object Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md This object defines the properties accepted by the optional parameter of the twemoji.parse function. These properties allow customization of how emoji are rendered, including image sources, attributes, base URL, file extensions, class names, size, and folder. ```javascript { callback: Function, // default the common replacer attributes: Function, // default returns {} base: string, // default MaxCDN ext: string, // default ".png" className: string, // default "emoji" size: string|number, // default "36x36" folder: string // in case it's specified // it replaces .size info, if any } ``` -------------------------------- ### Convert Code Point to Surrogate Pairs Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Use this function to convert a HEX codepoint into its corresponding UTF-16 surrogate pairs. The output is a string representing the surrogate pairs. ```javascript twemoji.convert.fromCodePoint('1f1e8'); // "\ud83c\udde8" ``` -------------------------------- ### Copy Emoji to Clipboard on Click Source: https://github.com/twitter/twemoji/blob/master/src/templates/preview.html This snippet adds click event listeners to all emoji images within the document. When an emoji image is clicked, it prompts the user to copy the emoji's alt text (the emoji itself) to the clipboard using a keyboard shortcut (Ctrl+C or Command+C). ```javascript (function (img, metaKey, i) { function copyToClipboard(e) { prompt('Copy to clipboard via ' + metaKey + '+C and Enter', this.alt); } for (i = 0; i < img.length; img[i++].onclick = copyToClipboard) {} }( document.getElementsByTagName('img'), /\b(?:Mac |i)OS\b/i.test(navigator.userAgent) ? 'Command' : 'Ctrl' )); ``` -------------------------------- ### CSS for Inline Emoji Styling Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Apply this CSS to make emoji size dynamically with surrounding text. It ensures proper scaling, spacing, and vertical alignment. ```css img.emoji { height: 1em; width: 1em; margin: 0 .05em 0 .1em; vertical-align: -0.1em; } ``` -------------------------------- ### Basic CSS for Emoji Display Source: https://github.com/twitter/twemoji/blob/master/src/test/base.html This CSS provides basic styling for displaying emojis inline. It ensures emojis appear correctly sized and without default browser decorations. ```css img.emoji { display: inline !important; border: none !important; box-shadow: none !important; height: 1em !important; width: 1em !important; margin: 0 .07em !important; vertical-align: -0.1em !important; background: none !important; padding: 0 !important; } ``` -------------------------------- ### Add Click Handler to Copy Alt Text Source: https://github.com/twitter/twemoji/blob/master/src/test/preview-svg.html Adds a click event listener to all generated emoji images. When clicked, it prompts the user to copy the emoji's alt text using a keyboard shortcut (Command/Ctrl + C). ```javascript (function (img, metaKey, i) { function copyToClipboard(e) { prompt('Copy to clipboard via ' + metaKey + '+C and Enter', this.alt); } for (i = 0; i < img.length; img[i++].onclick = copyToClipboard) {} }( document.getElementsByTagName('img'), /\b(?:Mac |i)OS\b/i.test(navigator.userAgent) ? 'Command' : 'Ctrl' )); ``` -------------------------------- ### Twitter Widgets Script Source: https://github.com/twitter/twemoji/blob/master/index.html This script is used to load Twitter's widgets, such as the tweet button. It should be placed before the closing `` tag. ```javascript !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs'); ``` -------------------------------- ### twemoji.parse() - DOM Parsing Source: https://github.com/twitter/twemoji/blob/master/README.md The main parsing utility for replacing emoji within DOM elements. It targets `#text` nodes specifically, ensuring surrounding nodes and listeners are unaffected. This method is recommended for its safety and efficiency, though it incurs a slight performance cost due to DOM operations. ```APIDOC ## twemoji.parse(node, options) ### Description Parses emoji within a given DOM node, replacing them with image tags. It specifically targets text nodes within the provided element. ### Method `twemoji.parse()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters (Optional Object) An optional object can be passed as the second argument to `twemoji.parse` to customize parsing behavior: - **callback** (Function): The function to invoke to generate image sources. Defaults to a common replacer function. - **attributes** (Function): A function that returns an object of attributes for the generated image tags. Defaults to returning an empty object. - **base** (string): The base URL for emoji images. Defaults to the MaxCDN URL. - **ext** (string): The file extension for emoji images. Defaults to ".png". - **className** (string): The CSS class name for generated image tags. Defaults to "emoji". - **size** (string|number): The size of the emoji images. Defaults to "72x72". Can be overridden by the `folder` property. - **folder** (string): Specifies a folder for the emoji images, overriding the `size` property. Useful for formats like SVG. ### Request Example ```js var div = document.createElement('div'); div.textContent = 'I \u2764\uFE0F emoji!'; document.body.appendChild(div); twemoji.parse(document.body); // Example with options: twemoji.parse(document.body, { folder: 'svg', ext: '.svg' }); ``` ### Response #### Success Response Emoji characters within the specified DOM node are replaced with `` tags. The original node structure is preserved. #### Response Example ```js // After parsing, an img element might look like this: // \u2764\uFE0F ``` ### Error Handling This method does not explicitly define error handling for invalid input or parsing failures. ``` -------------------------------- ### Convert Surrogate Pairs to Code Point Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Converts UTF-16 surrogate pairs into their equivalent HEX codepoint. You can specify a custom separator character. ```javascript twemoji.convert.toCodePoint('\ud83c\udde8\ud83c\uddf3'); // "1f1e8-1f1f3" ``` ```javascript twemoji.convert.toCodePoint('\ud83c\udde8\ud83c\uddf3', '~'); // "1f1e8~1f1f3" ``` -------------------------------- ### Custom Attributes Callback Function Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md The function to invoke to generate custom attributes for the image tag. It receives the icon code point and variant, and should return an object of attributes. ```javascript function attributesCallback(icon, variant) { return { title: 'Emoji: ' + icon + variant }; } ``` -------------------------------- ### Set UTF-8 Character Set Meta Tag Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Ensure proper emoji support by setting the document's character set to UTF-8. Include this meta tag in the document's head. ```html ``` -------------------------------- ### Parse Twemoji and Measure Performance Source: https://github.com/twitter/twemoji/blob/master/src/templates/preview.html This snippet parses emoji from an unordered list and measures the time taken for the parsing operation. It then displays the total count of emoji and the elapsed time. ```javascript var ul = document.getElementsByTagName('ul')[0]; var total = ul.getElementsByTagName('li').length; var elapsed = +new Date; twemoji.parse(ul, {{emoji-options}}); elapsed = (+new Date) - elapsed; document.body.insertBefore( document.createTextNode(total + ' emoji parsed in ' + elapsed + 'ms'), document.body.firstChild ); ``` -------------------------------- ### Parse and Render Emoji with Twemoji Source: https://github.com/twitter/twemoji/blob/master/index.html Use this JavaScript snippet to parse and render emoji within the specified DOM element. Ensure the twemoji library is loaded before executing this code. ```javascript twemoji.parse(document.body); ``` -------------------------------- ### CSS for Emoji Container Source: https://github.com/twitter/twemoji/blob/master/src/test/base.html This CSS class is used to style a container for emojis, setting the font size for the emojis within it. ```css .emojis { margin-bottom: 20px; font-size: 32px; } ``` -------------------------------- ### twemoji.parse() - String Parsing Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Parses a given string, replacing all emoji with an tag. This method does not sanitize the string and should be used with caution on unsanitized input. ```APIDOC ## twemoji.parse(string) ### Description Replaces all emoji in a generic string with an `` tag. Use with caution as it does not sanitize input. ### Method `twemoji.parse(text: string): string` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript twemoji.parse('I \u2764\uFE0F emoji!'); ``` ### Response #### Success Response (string) Returns the string with emoji replaced by `` tags. #### Response Example ```html I ❤️ emoji! ``` ``` -------------------------------- ### twemoji.parse() with callback Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Parses and replaces emoji in the given scope, with an option to exclude specific characters via a callback function. ```APIDOC ## twemoji.parse() with callback ### Description To exclude certain characters from being replaced by twemoji.js, call twemoji.parse() with a callback, returning false for the specific unicode icon. ### Parameters #### Path Parameters - **scope** (Node) - Required - The DOM node to parse. - **options** (object) - Optional - Configuration options for parsing. - **callback** (function) - Optional - A callback function to determine whether to replace an icon. ### Request Example ```javascript twemoji.parse(document.body, { callback: function(icon, options, variant) { switch ( icon ) { case 'a9': // © copyright case 'ae': // ® registered trademark case '2122': // ™ trademark return false; } return ''.concat(options.base, options.size, '/', icon, options.ext); } }); ``` ``` -------------------------------- ### String Parsing with Falsy Callback Return Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md If the callback returns a falsy value (e.g., `null`, `undefined`, `false`), the specific emoji will not be replaced. ```javascript var i = 0; twemoji.parse( 'emoji, m ur', function(icon, options, variant) { if (i++ === 0) { return; // no changes made first call } return '/assets/' + icon + options.ext; } ); // will produce /* emoji, m❤️n am❤️ur */ ``` -------------------------------- ### twemoji.parse() - DOM Parsing Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Parses emoji within an HTMLElement, replacing them with `` tags directly within the DOM without using `innerHTML`. This is a safer option for security-sensitive applications. ```APIDOC ## twemoji.parse(element) ### Description Parses emoji within a given `HTMLElement`. It replaces emoji found in `#text` nodes with `` tags, preserving surrounding nodes and event listeners. This method is safer than string parsing as it avoids `innerHTML`. ### Method `twemoji.parse(element: HTMLElement): void` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript var div = document.createElement('div'); div.textContent = 'I \u2764\uFE0F emoji!'; document.body.appendChild(div); twemoji.parse(div); ``` ### Response #### Success Response (void) This method modifies the DOM in place and does not return a value. #### Response Example (No direct response, DOM is modified) ```html
    I ❤️ emoji!
    ``` ``` -------------------------------- ### DOM Parsing Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Replaces emoji within `#text` nodes of a given `HTMLElement` with `` tags without using `innerHTML`. This is a safer but potentially slower option. ```javascript var div = document.createElement('div'); div.textContent = 'I emoji!'; document.body.appendChild(div); twemoji.parse(document.body); var img = div.querySelector('img'); // note the div is preserved img.parentNode === div; // true img.src; // https://twemoji.maxcdn.com/36x36/2764.png img.alt; // img.className; // emoji img.draggable; // false ``` -------------------------------- ### Exclude Specific Characters with Callback Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Use a callback function with twemoji.parse() to prevent specific characters from being replaced. Return false for icons you wish to exclude. ```javascript twemoji.parse(document.body, { callback: function(icon, options, variant) { switch ( icon ) { case 'a9': // © copyright case 'ae': // ® registered trademark case '2122': // ™ trademark return false; } return ''.concat(options.base, options.size, '/', icon, options.ext); } }); ``` -------------------------------- ### Parse Emojis and Measure Time Source: https://github.com/twitter/twemoji/blob/master/src/test/preview-svg.html Parses all emoji characters within a UL element and measures the time taken. The parsed SVGs are configured to use a specific folder and extension. ```javascript var ul = document.getElementsByTagName('ul')[0]; var total = ul.getElementsByTagName('li').length; var elapsed = +new Date; twemoji.parse(ul, {"folder":"../../assets/svg","ext":".svg","base":""}); elapsed = (+new Date) - elapsed; document.body.insertBefore( document.createTextNode(total + ' emoji parsed in ' + elapsed + 'ms'), document.body.firstChild ); ``` -------------------------------- ### Parse Emoji in a String Source: https://github.com/twitter/twemoji/blob/master/LEGACY.md Replaces all emoji in a given string with `` tags. This method is safe for already sanitized strings but does not sanitize input itself. ```javascript twemoji.parse('I emoji!'); // will produce /* I ❤️ emoji! */ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.