{"id":13399166,"url":"https://github.com/twitter/twemoji","last_synced_at":"2025-05-12T03:45:53.415Z","repository":{"id":22942349,"uuid":"26291683","full_name":"twitter/twemoji","owner":"twitter","description":"Emoji for everyone. https://twemoji.twitter.com/","archived":false,"fork":false,"pushed_at":"2024-08-16T08:40:12.000Z","size":843480,"stargazers_count":17040,"open_issues_count":117,"forks_count":1878,"subscribers_count":333,"default_branch":"master","last_synced_at":"2025-05-08T14:03:17.003Z","etag":null,"topics":["emoji","twemoji"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/twitter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-11-06T21:49:34.000Z","updated_at":"2025-05-07T14:17:23.000Z","dependencies_parsed_at":"2024-05-09T15:12:33.375Z","dependency_job_id":"c06e4295-ca63-4e96-a896-733a096003c3","html_url":"https://github.com/twitter/twemoji","commit_stats":{"total_commits":375,"total_committers":73,"mean_commits":5.136986301369863,"dds":0.7413333333333334,"last_synced_commit":"d94f4cf793e6d5ca592aa00f58a88f6a4229ad43"},"previous_names":[],"tags_count":74,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitter%2Ftwemoji","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitter%2Ftwemoji/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitter%2Ftwemoji/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitter%2Ftwemoji/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twitter","download_url":"https://codeload.github.com/twitter/twemoji/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253282908,"owners_count":21883528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emoji","twemoji"],"created_at":"2024-07-30T19:00:34.797Z","updated_at":"2025-05-12T03:45:53.393Z","avatar_url":"https://github.com/twitter.png","language":"HTML","funding_links":[],"categories":["JavaScript","HTML","Open Source Custom Emoji","Miscellaneous","📝 3. Building the cheatsheet","emoji","Emoji","前端开发框架及项目","目录","Emojis"],"sub_categories":["Free","Markdown","其他_文本生成、文本对话"],"readme":"# Twitter Emoji (Twemoji) [![Build Status](https://travis-ci.org/twitter/twemoji.svg?branch=gh-pages)](https://travis-ci.org/twitter/twemoji)\n\nA simple library that provides standard Unicode [emoji](http://en.wikipedia.org/wiki/Emoji) support across all platforms.\n\n**Twemoji v14.0** adheres to the [Unicode 14.0 spec](https://unicode.org/versions/Unicode14.0.0/) and supports the [Emoji 14.0 spec](https://www.unicode.org/reports/tr51/tr51-21.html). _We do not support custom emoji._\n\nThe Twemoji library offers support for all Unicode-defined emoji which are recommended for general interchange (RGI).\n\n## Usage\n\n### CDN Support\n\n\u003cdel\u003eThe folks over at [MaxCDN](https://www.maxcdn.com) have graciously provided CDN support.\u003c/del\u003e\n\nMaxCDN is shut down right now, so in the meanwhile use a different CDN or download the assets. (See [Maxcdn has shut down, cdn not working anymore. · Issue #580 · twitter/twemoji](https://github.com/twitter/twemoji/issues/580)).\n\nUse the following in the `\u003chead\u003e` tag of your HTML document(s):\n\n```html\n\u003cscript src=\"https://unpkg.com/twemoji@latest/dist/twemoji.min.js\" crossorigin=\"anonymous\"\u003e\u003c/script\u003e\n```\n\nThis guarantees that you will always use the latest version of the library.\n\nIf, instead, you'd like to include the latest version explicitly, you can add the following tag:\n```html\n\u003cscript src=\"https://unpkg.com/twemoji@14.0.2/dist/twemoji.min.js\" integrity=\"sha384-ICOlZarapRIX6UjKPcWKEpubjg7lGADN7Y9fYP4DU9zm0aPFhgnP5ef+XFaPyKv+\" crossorigin=\"anonymous\"\u003e\u003c/script\u003e\n```\n\n### Download\n\nIf instead you want to download a specific version, please look at the `gh-pages` branch, where you will find the built assets for both our latest and older versions.\n\n## API\n\nFollowing are all the methods exposed in the `twemoji` namespace.\n\n### twemoji.parse( ... ) V1\n\nThis is the main parsing utility and has 3 overloads per parsing type.\n\nAlthough there are two kinds of parsing supported by this utility, we recommend you use [DOM parsing](https://github.com/twitter/twemoji#dom-parsing), explained below. Each type of parsing accepts a callback to generate an image source or an options object with parsing info.\n\nThe second kind of parsing is string parsing, explained in the legacy documentation [here](https://github.com/twitter/twemoji/blob/master/LEGACY.md#string-parsing). This is unrecommended because this method does not sanitize the string or otherwise prevent malicious code from being executed; such sanitization is out of scope.\n\n#### DOM parsing\n\nIf the first argument to `twemoji.parse` is an `HTMLElement`, generated image tags will replace emoji that are **inside `#text` nodes only** without compromising surrounding nodes or listeners, and completely avoiding the usage of `innerHTML`.\n\nIf security is a major concern, this parsing can be considered the safest option but with a slight performance penalty due to DOM operations that are inevitably *costly*.\n\n```js\nvar div = document.createElement('div');\ndiv.textContent = 'I \\u2764\\uFE0F emoji!';\ndocument.body.appendChild(div);\n\ntwemoji.parse(document.body);\n\nvar img = div.querySelector('img');\n\n// note the div is preserved\nimg.parentNode === div; // true\n\nimg.src;        // https://twemoji.maxcdn.com/v/latest/72x72/2764.png\nimg.alt;        // \\u2764\\uFE0F\nimg.className;  // emoji\nimg.draggable;  // false\n\n```\n\nAll other overloads described for `string` are available in exactly the same way for DOM parsing.\n\n### Object as parameter\n\nHere's the list of properties accepted by the optional object that can be passed to the `parse` function.\n\n```js\n  {\n    callback: Function,   // default the common replacer\n    attributes: Function, // default returns {}\n    base: string,         // default MaxCDN\n    ext: string,          // default \".png\"\n    className: string,    // default \"emoji\"\n    size: string|number,  // default \"72x72\"\n    folder: string        // in case it's specified\n                          // it replaces .size info, if any\n  }\n```\n\n#### callback\n\nThe function to invoke in order to generate image `src`(s).\n\nBy default it is a function like the following one:\n\n```js\nfunction imageSourceGenerator(icon, options) {\n  return ''.concat(\n    options.base, // by default Twitter Inc. CDN\n    options.size, // by default \"72x72\" string\n    '/',\n    icon,         // the found emoji as code point\n    options.ext   // by default \".png\"\n  );\n}\n```\n\n#### base\n\nThe default url is the same as `twemoji.base`, so if you modify the former, it will reflect as default for all parsed strings or nodes.\n\n#### ext\n\nThe default image extension is the same as `twemoji.ext` which is `\".png\"`.\n\nIf you modify the former, it will reflect as default for all parsed strings or nodes.\n\n#### className\n\nThe default `class` for each generated image is `emoji`. It is possible to specify a different one through this property.\n\n##### size\n\nThe default asset size is the same as `twemoji.size` which is `\"72x72\"`.\n\nIf you modify the former, it will reflect as default for all parsed strings or nodes.\n\n#### folder\n\nIn case you don't want to specify a size for the image. It is possible to choose a folder, as in the case of SVG emoji.\n\n```js\ntwemoji.parse(genericNode, {\n  folder: 'svg',\n  ext: '.svg'\n});\n```\n\nThis will generate urls such `https://twemoji.maxcdn.com/svg/2764.svg` instead of using a specific size based image.\n\n## Utilities\n\nBasic utilities / helpers to convert code points to JavaScript surrogates and vice versa.\n\n### twemoji.convert.fromCodePoint()\n\nFor a given HEX codepoint, returns UTF-16 surrogate pairs.\n\n```js\ntwemoji.convert.fromCodePoint('1f1e8');\n // \"\\ud83c\\udde8\"\n```\n\n### twemoji.convert.toCodePoint()\n\nFor given UTF-16 surrogate pairs, returns the equivalent HEX codepoint.\n\n```js\n twemoji.convert.toCodePoint('\\ud83c\\udde8\\ud83c\\uddf3');\n // \"1f1e8-1f1f3\"\n\n twemoji.convert.toCodePoint('\\ud83c\\udde8\\ud83c\\uddf3', '~');\n // \"1f1e8~1f1f3\"\n```\n\n## Tips\n\n### Inline Styles\n\nIf you'd like to size the emoji according to the surrounding text, you can add the following CSS to your stylesheet:\n\n```css\nimg.emoji {\n   height: 1em;\n   width: 1em;\n   margin: 0 .05em 0 .1em;\n   vertical-align: -0.1em;\n}\n```\n\nThis will make sure emoji derive their width and height from the `font-size` of the text they're shown with. It also adds just a little bit of space before and after each emoji, and pulls them upwards a little bit for better optical alignment.\n\n### UTF-8 Character Set\n\nTo properly support emoji, the document character set must be set to UTF-8. This can be done by including the following meta tag in the document `\u003chead\u003e`\n\n```html\n\u003cmeta charset=\"utf-8\"\u003e\n```\n\n### Exclude Characters (V1)\n\nTo exclude certain characters from being replaced by twemoji.js, call twemoji.parse() with a callback, returning false for the specific unicode icon. For example:\n\n```js\ntwemoji.parse(document.body, {\n    callback: function(icon, options, variant) {\n        switch ( icon ) {\n            case 'a9':      // © copyright\n            case 'ae':      // ® registered trademark\n            case '2122':    // ™ trademark\n                return false;\n        }\n        return ''.concat(options.base, options.size, '/', icon, options.ext);\n    }\n});\n```\n\n## Legacy API (V1)\n\nIf you're still using our V1 API, you can read our legacy documentation [here](https://github.com/twitter/twemoji/tree/master/LEGACY.md).\n\n## Contributing\n\nThe contributing documentation can be found [here](https://github.com/twitter/twemoji/tree/master/CONTRIBUTING.md).\n\n## Attribution Requirements\n\nAs an open source project, attribution is critical from a legal, practical and motivational perspective in our opinion. The graphics are licensed under the CC-BY 4.0 which has a pretty good guide on [best practices for attribution](https://wiki.creativecommons.org/Best_practices_for_attribution).\n\nHowever, we consider the guide a bit onerous and as a project, will accept a mention in a project README or an 'About' section or footer on a website. In mobile applications, a common place would be in the Settings/About section (for example, see the mobile Twitter application Settings-\u003eAbout-\u003eLegal section). We would consider a mention in the HTML/JS source sufficient also.\n\n## Community Projects\n\n* [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app) by [@ShahriarKh](https://github.com/ShahriarKh): An easy-to-use cheatsheet for exploring, copying and downloading emojis!\n* [Twemoji Amazing](https://github.com/SebastianAigner/twemoji-amazing) by [@SebastianAigner](https://github.com/SebastianAigner): Use Twemoji using CSS classes (like [Font Awesome](http://fortawesome.github.io/Font-Awesome/)).\n* [Twemoji Ruby](https://github.com/jollygoodcode/twemoji) by [@JollyGoodCode](https://twitter.com/jollygoodcode): Use Twemoji in Ruby.\n* [Twemoji Utils](https://github.com/gustavwilliam/twemoji-utils) by [@gustavwilliam](https://github.com/gustavwilliam): Utilities for finding and downloading Twemoji source files.\n* [Twemoji for Pencil](https://github.com/nathanielw/Twemoji-for-Pencil) by [@Nathanielnw](https://twitter.com/nathanielnw): Use Twemoji in Pencil.\n* [FrwTwemoji - Twemoji in dotnet](http://github.frenchw.net/FrwTwemoji/) by [@FrenchW](https://twitter.com/frenchw): Use Twemoji in any dotnet project (C#, asp.net ...).\n* [Emojiawesome - Twemoji for Yellow](https://github.com/datenstrom/yellow-extensions/tree/master/source/emojiawesome) by [@datenstrom](https://github.com/datenstrom/): Use Twemoji on your website.\n* [EmojiPanel for Twitter](https://github.com/danbovey/EmojiPanel) by [@danielbovey](https://twitter.com/danielbovey/status/749580050274582528): Insert Twemoji into your tweets on twitter.com.\n* [Twitter Color Emoji font](https://github.com/eosrei/twemoji-color-font) by [@bderickson](https://twitter.com/bderickson): Use Twemoji as your system default font on Linux \u0026 OS X.\n* [Emojica](https://github.com/xoudini/emojica) by [@xoudini](https://twitter.com/xoudini): An iOS framework allowing you to replace all standard emoji in strings with Twemoji.\n* [gwt-twemoji](https://github.com/phpmonkeys-de/gwt-twemoji) by [@nbartels](https://github.com/nbartels): Use Twemoji in GWT\n* [JavaFXEmojiTextFlow](https://github.com/pavlobu/emoji-text-flow-javafx) by [@pavlobu](https://github.com/pavlobu): A JavaFX library allowing you to replace all standard emoji in extended EmojiTextFlow with Twemoji.\n* [Vue Twemoji Picker](https://github.com/kevinfaguiar/vue-twemoji-picker) by [@kevinfaguiar](https://github.com/kevinfaguiar): A fast plug-n-play Twemoji Picker (+textarea for Twemoji rendering) for Vue.\n* [Unmaintained] [Twemoji Awesome](http://ellekasai.github.io/twemoji-awesome/) by [@ellekasai](https://twitter.com/ellekasai/): Use Twemoji using CSS classes (like [Font Awesome](http://fortawesome.github.io/Font-Awesome/)).\n* [EmojiOnRoku](https://github.com/KasperGam/EmojiOnRoku) by [@KasperGam](https://github.com/KasperGam): Use Twemoji on Roku!\n* [LaTeX Twemoji](https://gitlab.com/rossel.jost/latex-twemojis) by [@rossel.jost](https://gitlab.com/rossel.jost): Use Twemoji in LaTeX.\n* [PHP Twemoji](https://github.com/Astrotomic/php-twemoji) by [@Astrotomic](https://github.com/Astrotomic): Use twemoji within your PHP website project's by replacing standard Emoji with twemoji urls.\n\n## Committers and Contributors\n\n* Justine De Caires (Twitter)\n* Jason Sofonia (Twitter)\n* Bryan Haggerty (ex-Twitter)\n* Nathan Downs (ex-Twitter)\n* Tom Wuttke (ex-Twitter)\n* Andrea Giammarchi (ex-Twitter)\n* Joen Asmussen (WordPress)\n* Marcus Kazmierczak (WordPress)\n\nThe goal of this project is to simply provide emoji for everyone. We definitely welcome improvements and fixes, but we may not merge every pull request suggested by the community due to the simple nature of the project.\n\nThe rules for contributing are available in the `CONTRIBUTING.md` file.\n\nThank you to all of our [contributors](https://github.com/twitter/twemoji/graphs/contributors).\n\n## License\n\nCopyright 2019 Twitter, Inc and other contributors\n\nCode licensed under the MIT License: \u003chttp://opensource.org/licenses/MIT\u003e\n\nGraphics licensed under CC-BY 4.0: \u003chttps://creativecommons.org/licenses/by/4.0/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwitter%2Ftwemoji","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwitter%2Ftwemoji","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwitter%2Ftwemoji/lists"}