{"id":18774190,"url":"https://github.com/leny/figi","last_synced_at":"2025-12-14T06:30:16.305Z","repository":{"id":16030494,"uuid":"18774253","full_name":"leny/figi","owner":"leny","description":"Parse emoticons in text and replace by html images... or whatever you need.","archived":false,"fork":false,"pushed_at":"2019-10-22T18:50:14.000Z","size":26,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-29T20:49:32.410Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-14T19:51:36.000Z","updated_at":"2019-10-22T18:50:16.000Z","dependencies_parsed_at":"2022-08-31T01:22:22.063Z","dependency_job_id":null,"html_url":"https://github.com/leny/figi","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Ffigi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Ffigi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Ffigi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Ffigi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leny","download_url":"https://codeload.github.com/leny/figi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239680988,"owners_count":19679509,"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":[],"created_at":"2024-11-07T19:37:42.025Z","updated_at":"2025-12-14T06:30:16.234Z","avatar_url":"https://github.com/leny.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# figi\n\n![NPM version](http://img.shields.io/npm/v/figi.svg) ![Build Status](http://img.shields.io/travis/leny/figi.svg) ![Dependency Status](https://david-dm.org/leny/figi.svg) ![Downloads counter](http://img.shields.io/npm/dm/figi.svg) [![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)\n\n\u003e Parse emoticons in text and replace by html images... or whatever you need.\n\n* * *\n\n## Warning: breaking changes with version `1.0.0`\n\nWith version `1.0.0`, **figi** drop the UMD implementation and node version prior to 4.0 to use the ES6 module definition.  \nFor now, it uses Babel to transpile to ES5.\n\nSo, if you use ES5, you should require figi with `var figi = require( \"figi\" ).default;`, and, if you use ES6, you should import figi with `import figi from \"figi\";`.\n\n* * *\n\n## Getting Started\n\n### From **browsers** and **node**.\n\nInstall the module with: `npm install figi`\n\n### Simple usage\n\nSee **documentation** for more informations.\n\n```javascript\nvar figi = require( \"figi\" ).default;\n\nfigi.catalog = {\n    \":)\": \"smile.png\",\n    \";)\": \"wink.png\",\n    \":D\": \"lol.png\"\n};\n\nvar str = figi( \"I'm happy ;) !\" ); // \"I'm happy \u003cimg src=\"./wink.png\" alt=\";)\" class=\"emote\" /\u003e !\"\n```\n\n## Documentation\n\n**figi** find predefined sequences in strings and returns the strings with `\u003cimg /\u003e` tags for finded sequences.\n\nThe first purpose of **figi** is, of course, to find and replace emoticons by images.\n\n### Setup **figi**\n\n#### catalog\n\nAt least, **figi** needs a catalog of strings to find and replace in your strings.\n\nBy default, the catalog of **figi** is *empty* : it search and replace nothing.\n\nTo define it globaly, you can pass your catalog to `figi.catalog`, as in the following example :\n\n```javascript\nfigi.catalog = {\n    \":)\": \"smile.png\",\n    \";)\": \"wink.png\",\n    \":D\": \"lol.png\"\n};\n```\n\n**figi** will only use the `string` keys, the other key types will be ignored. The value of a key *should* be a string, but you can do whatever you want if you redefine the parser (see below).\n\n#### classes\n\nBy default, **figi** add the unique `emote` class on the resulting `\u003cimg /\u003e` tags. You can provide a `string` or an `array` of strings to `figi.classes`.\n\n```javascript\nfigi.classes = \"smiley little red\";\n```\n\n```javascript\nfigi.classes = [ \"smiley\", \"little\", \"red\" ];\n```\n\n#### base path\n\nBy default, **figi** use the `./` base path for emoticon images. You can replace it by passing a `string` to `figi.path`.\n\n```javascript\nfigi.path = \"http://mysite.com/images/emotes/\";\n```\n\n#### replacer\n\nBy default, **figi** replace each key of the catalog by an `\u003cimg /\u003e` tag with an `src` attribute (the *value* of the key, prefixed by the path), an `alt` attribute (the key), and a `class` attribute (by default, the class *emote*).\n\nYou can change the replacement by anything you want by passing a function to `figi.replacer`.\n\nThis function will receive two arguments : the value and the key, and must return the replaced value of the key, to be substitute in the original string. Inside the `replacer` function, the `this` context will be the `figi` instance, to access the predefined values, as in the following example.\n\n```javascript\nfigi.replacer = function( value, key ) {\n    return '\u003ci data-icon=\"' + this.path + value + '\" title=\"' + key + '\"\u003e' + key + '\u003c/i\u003e';\n};\n```\n\n### use **figi**\n\n#### Using globally-setted config values.\n\nUsing **figi** is very simple :\n\n```javascript\nvar inputString = \"Hi, I love to use emoticon like this :) in my texts. And to replace these by images, I use figi ! ;)\";\n\nvar parsedString = figi( inputString );\n```\n\nThe `parsedString` var will be :\n\n`Hi, I love to use emoticon like this \u003cimg src=\"./smile.png\" alt=\":)\" class=\"emote\" /\u003e in my texts. And to replace these by images, I use figi ! \u003cimg src=\"./wink.png\" alt=\";)\" class=\"emote\" /\u003e`\n\n#### Using local config values.\n\nYou can also use **figi** with local config values when you call it, like this :\n\n```javascript\nvar inputString = \"Hi, I love to use emoticon like this :) in my texts. And to replace these by images, I use figi ! ;)\";\n\nvar parsedString = figi( inputString, {\n    catalog: {\n        \":)\": \"round-smile.png\",\n        \";)\": \"round-wink.png\"\n    },\n    classes: \"little smiley\",\n    path: \"./img/emotes/\"\n} );\n```\n\nThe `parsedString` var will be :\n\n`Hi, I love to use emoticon like this \u003cimg src=\"./img/emotes/round-smile.png\" alt=\":)\" class=\"little smiley\" /\u003e in my texts. And to replace these by images, I use figi ! \u003cimg src=\"./img/emotes/round-wink.png\" alt=\";)\" class=\"little smiley\" /\u003e`\n\n## Contributing\n\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n## Release History\n\n* **1.0.0**: Drop UMD support, use ES6 module definition (*17/01/16*)\n* **0.1.4**: Updating dependencies (*12/10/14*)\n* **0.1.3**: Remove support for node 0.8 (*31/05/14*)\n* **0.1.2**: Fix issue #1 (*31/05/14*)\n* **0.1.1**: Optimisation (*12/05/14*)\n* **0.1.0**: Initial release (*15/04/14*)\n\n## License\n(Un)licensed under the UNLICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleny%2Ffigi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleny%2Ffigi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleny%2Ffigi/lists"}