retext-emoji
Advanced tools
Comparing version
@@ -1,76 +0,11 @@ | ||
<!--mdast setext--> | ||
<!--remark setext--> | ||
<!--lint disable no-multiple-toplevel-headings--> | ||
<!--lint disable maximum-line-length--> | ||
1.0.0 / 2015-08-30 | ||
2.0.0 / 2016-06-22 | ||
================== | ||
* Update module for retext@1.0.0 ([864cfe6](https://github.com/wooorm/retext-emoji/commit/864cfe6)) | ||
* Refactor module ([`a26ef64`](https://github.com/wooorm/retext-emoji/commit/a26ef64)) | ||
0.5.4 / 2015-01-19 | ||
1.0.0 / 2015-08-30 | ||
================== | ||
* Update retext ([5afba9b](https://github.com/wooorm/retext-emoji/commit/5afba9b)) | ||
0.5.3 / 2014-12-14 | ||
================== | ||
* Update emoticon, retext ([a1d49d6](https://github.com/wooorm/retext-emoji/commit/a1d49d6)) | ||
0.5.2 / 2014-12-03 | ||
================== | ||
* Add nlcst-affix-emoticon-modifier to dependencies ([3e0c7c9](https://github.com/wooorm/retext-emoji/commit/3e0c7c9)) | ||
0.5.1 / 2014-12-02 | ||
================== | ||
* Remove duplicate emoticon dependency from dev-dependencies ([f225ebb](https://github.com/wooorm/retext-emoji/commit/f225ebb)) | ||
0.5.0 / 2014-12-02 | ||
================== | ||
* Add support for encoding and decoding emoticons ([7ccbe13](https://github.com/wooorm/retext-emoji/commit/7ccbe13)) | ||
* Add emoticon as a dependency ([666f519](https://github.com/wooorm/retext-emoji/commit/666f519)) | ||
* Add nlcst-emoticon-modifier as a dependency ([81c04f3](https://github.com/wooorm/retext-emoji/commit/81c04f3)) | ||
0.4.1 / 2014-11-22 | ||
================== | ||
* Update retext, retext-inspect ([9bab88d](https://github.com/wooorm/retext-emoji/commit/9bab88d)) | ||
0.4.0 / 2014-11-19 | ||
================== | ||
* Add nlcst-emoji-modifier as a dependency ([dcd63b6](https://github.com/wooorm/retext-emoji/commit/dcd63b6)) | ||
0.3.0 / 2014-10-28 | ||
================== | ||
* Refactor for changes in retext ([8c18b35](https://github.com/wooorm/retext-emoji/commit/8c18b35)) | ||
0.2.0 / 2014-10-21 | ||
================== | ||
* Update module for changes in retext ([90bf6a3](https://github.com/wooorm/retext-emoji/commit/90bf6a3)) | ||
* Add nlcst-to-string to dependencies ([05024d4](https://github.com/wooorm/retext-emoji/commit/05024d4)) | ||
0.1.3 / 2014-10-15 | ||
================== | ||
* Update gemoji, retext, retext-ast ([36318f3](https://github.com/wooorm/retext-emoji/commit/36318f3)) | ||
0.1.2 / 2014-09-27 | ||
================== | ||
* Refactor API ([9bbf8e4](https://github.com/wooorm/retext-emoji/commit/9bbf8e4)) | ||
0.1.1 / 2014-09-08 | ||
================== | ||
* Fix failing emoji (closes [GH-3](https://github.com/wooorm/retext-emoji/issues/3)) ([2f262b6](https://github.com/wooorm/retext-emoji/commit/2f262b6)) | ||
0.1.0 / 2014-07-13 | ||
================== |
45
index.js
/** | ||
* @author Titus Wormer | ||
* @copyright 2014-2015 Titus Wormer | ||
* @copyright 2014 Titus Wormer | ||
* @license MIT | ||
* @module retext:emoji | ||
* @fileoverview Retext support for emoji, gemoji, and emoticon. | ||
* @module retext-emoji | ||
* @fileoverview Emoji, gemoji, and emoticons with retext. | ||
*/ | ||
@@ -13,6 +13,3 @@ | ||
/* | ||
* Dependencies. | ||
*/ | ||
/* Dependencies. */ | ||
var affixEmoticonModifier = require('nlcst-affix-emoticon-modifier'); | ||
@@ -26,19 +23,19 @@ var emoticonModifier = require('nlcst-emoticon-modifier'); | ||
/* | ||
* Constants. | ||
*/ | ||
/* Constants. */ | ||
var EMOTICON_NODE = 'EmoticonNode'; | ||
/* | ||
* Easy access. | ||
*/ | ||
/* Map of visitors. */ | ||
var fns = { | ||
encode: toEmoji, | ||
decode: toGemoji | ||
} | ||
/* Easy access. */ | ||
var unicodes = gemoji.unicode; | ||
var names = gemoji.name; | ||
var shortcodes = {}; | ||
emoticons = emoticons.emoticon; | ||
var shortcodes = {}; | ||
(function () { | ||
@@ -88,11 +85,2 @@ var key; | ||
/* | ||
* Map of visitors. | ||
*/ | ||
var fns = { | ||
'encode': toEmoji, | ||
'decode': toGemoji | ||
} | ||
/** | ||
@@ -102,3 +90,3 @@ * Partially applied visit factory. | ||
* @param {Function?} transformer - EmoticonNode-visitor. | ||
* @return {Function?} | ||
* @return {Function?} - Vititor. | ||
*/ | ||
@@ -160,6 +148,3 @@ function visitFactory(transformer) { | ||
/* | ||
* Expose. | ||
*/ | ||
/* Expose. */ | ||
module.exports = emoji; |
{ | ||
"name": "retext-emoji", | ||
"version": "1.0.0", | ||
"description": "Retext support for emoji, gemoji, and emoticon", | ||
"version": "2.0.0", | ||
"description": "Emoji, gemoji, and emoticons with retext", | ||
"license": "MIT", | ||
@@ -12,2 +12,14 @@ "keywords": [ | ||
], | ||
"files": [ | ||
"index.js" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wooorm/retext-emoji.git" | ||
}, | ||
"bugs": "https://github.com/wooorm/retext-emoji/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
"contributors": [ | ||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)" | ||
], | ||
"dependencies": { | ||
@@ -19,43 +31,33 @@ "emoticon": "^1.0.0", | ||
"nlcst-emoticon-modifier": "^1.0.0", | ||
"nlcst-to-string": "^1.0.0", | ||
"nlcst-to-string": "^2.0.0", | ||
"unist-util-visit": "^1.0.0" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wooorm/retext-emoji.git" | ||
}, | ||
"author": "Titus Wormer <tituswormer@gmail.com>", | ||
"devDependencies": { | ||
"browserify": "^11.0.1", | ||
"eslint": "^1.0.0", | ||
"browserify": "^13.0.1", | ||
"eslint": "^2.0.0", | ||
"esmangle": "^1.0.1", | ||
"istanbul": "^0.3.0", | ||
"jscs": "^2.0.0", | ||
"jscs-jsdoc": "^1.0.0", | ||
"mdast": "^1.0.0", | ||
"mdast-comment-config": "^1.0.0", | ||
"mdast-github": "^1.0.0", | ||
"mdast-lint": "^1.0.0", | ||
"mdast-slug": "^1.0.0", | ||
"mdast-validate-links": "^1.0.0", | ||
"mocha": "^2.0.0", | ||
"retext": "^1.0.0-rc.4" | ||
"istanbul": "^0.4.0", | ||
"jscs": "^3.0.0", | ||
"jscs-jsdoc": "^2.0.0", | ||
"remark-cli": "^1.0.0", | ||
"remark-comment-config": "^4.0.0", | ||
"remark-github": "^5.0.0", | ||
"remark-lint": "^4.0.0", | ||
"remark-usage": "^4.0.0", | ||
"remark-validate-links": "^4.0.0", | ||
"retext": "^3.0.0", | ||
"tape": "^4.0.0" | ||
}, | ||
"scripts": { | ||
"test-api": "mocha --check-leaks test/index.js", | ||
"test-coverage": "istanbul cover _mocha -- test/index.js", | ||
"test-travis": "npm run test-coverage", | ||
"test": "npm run test-api", | ||
"build-md": "remark . --quiet --frail", | ||
"build-bundle": "browserify index.js --bare -s retextEmoji > retext-emoji.js", | ||
"build-mangle": "esmangle retext-emoji.js > retext-emoji.min.js", | ||
"build": "npm run build-md && npm run build-bundle && npm run build-mangle", | ||
"lint-api": "eslint .", | ||
"lint-style": "jscs --reporter inline .", | ||
"lint": "npm run lint-api && npm run lint-style", | ||
"make": "npm run lint && npm run test-coverage", | ||
"bundle": "browserify index.js --no-builtins -s retextEmoji > retext-emoji.js", | ||
"postbundle": "esmangle retext-emoji.js > retext-emoji.min.js", | ||
"build-md": "mdast . --quiet", | ||
"build": "npm run bundle && npm run build-md" | ||
"test-api": "node test/index.js", | ||
"test-coverage": "istanbul cover test/index.js", | ||
"test": "npm run build && npm run lint && npm run test-coverage" | ||
} | ||
} |
115
readme.md
@@ -1,8 +0,10 @@ | ||
# retext-emoji [](https://travis-ci.org/wooorm/retext-emoji) [](https://codecov.io/github/wooorm/retext-emoji) | ||
# retext-emoji [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
Emoji, gemoji, and emoticons in [**retext**](https://github.com/wooorm/retext). | ||
<!--lint disable heading-increment list-item-spacing--> | ||
Emoji, gemoji, and emoticons in [**retext**][retext]. | ||
## Installation | ||
[npm](https://docs.npmjs.com/cli/install): | ||
[npm][npm-install]: | ||
@@ -13,18 +15,20 @@ ```bash | ||
**retext-emoji** is also available for [bower](http://bower.io/#install-packages), | ||
and [duo](http://duojs.org/#getting-started), and as an AMD, CommonJS, and | ||
globals module, [uncompressed](retext-emoji.js) and [compressed](retext-emoji.min.js). | ||
**retext-emoji** is also available as an AMD, CommonJS, and | ||
globals module, [uncompressed and compressed][releases]. | ||
## Usage | ||
```js | ||
Dependencies: | ||
```javascript | ||
var retext = require('retext'); | ||
var emoji = require('retext-emoji'); | ||
var inspect = require('unist-util-inspect'); | ||
``` | ||
retext().use(emoji).use(function () { | ||
return function (node) { | ||
console.log(inspect(node)); | ||
} | ||
}).process('Iām going to bed. :zzz:'); | ||
Process: | ||
```javascript | ||
var file = retext() | ||
.use(emoji, {convert: 'encode'}) | ||
.process('Iām going to bed. :zzz:'); | ||
``` | ||
@@ -35,21 +39,3 @@ | ||
```text | ||
RootNode[1] | ||
āā ParagraphNode[1] | ||
āā SentenceNode[10] | ||
āā WordNode[3] | ||
ā āā TextNode: 'I' | ||
ā āā PunctuationNode: 'ā' | ||
ā āā TextNode: 'm' | ||
āā WhiteSpaceNode: ' ' | ||
āā WordNode[1] | ||
ā āā TextNode: 'going' | ||
āā WhiteSpaceNode: ' ' | ||
āā WordNode[1] | ||
ā āā TextNode: 'to' | ||
āā WhiteSpaceNode: ' ' | ||
āā WordNode[1] | ||
ā āā TextNode: 'bed' | ||
āā PunctuationNode: '.' | ||
āā WhiteSpaceNode: ' ' | ||
āā EmoticonNode: ':zzz:' [data={"names":["zzz"],"description":"sleeping symbol","tags":["sleeping"]}] | ||
Iām going to bed. š¤ | ||
``` | ||
@@ -59,28 +45,27 @@ | ||
### [retext](https://github.com/wooorm/retext/tree/feature/stable#api).[use](https://github.com/wooorm/retext/tree/feature/stable#retextuseplugin-options)(emoji\[, options\]) | ||
### `retext().use(emoji[, options])` | ||
Emoji, gemoji, and emoticons in [**retext**](https://github.com/wooorm/retext). | ||
Emoji, gemoji, and emoticons in [**retext**][retext]. | ||
**Parameters** | ||
###### `options` | ||
* `emoji` ā This plug-in; | ||
* `convert` (`'encode'` or `'decode'`, optional) | ||
ā When `encode`, converts short-codes and emoticons to their | ||
unicode equivalent (`:heart:` and `<3` to `ā¤ļø`); When `decode`, | ||
converts unicode emoji and emoticons to their short-code equivalent | ||
(`ā¤ļø` and `<3` to `:heart:`). | ||
* `options` (`Object`, optional): | ||
###### Returns | ||
* `convert` (`"encode"` or `"decode"`, optional) | ||
ā When `encode`, converts short-codes into their unicode equivalent | ||
(e.g., `:heart:` and `<3` to `ā¤ļø`); When `decode`, converts unicode | ||
emoji into their short-code equivalent (e.g., `ā¤ļø` and `<3` to | ||
`:heart:`). | ||
`string`. | ||
### EmoticonNode | ||
### `EmoticonNode` | ||
**retext-emoji** adds a new node to [NLCST](https://github.com/wooorm/nlcst), | ||
namely, the `EmoticonNode` ([SymbolNode](https://github.com/wooorm/nlcst#symbolnode)). | ||
**retext-emoji** adds a new node to [NLCST][]: `Emoticon` ([Symbol][]). | ||
Whether emoji (`ā¤ļø`), emoticon (`<3`), or gemoji (`:heart:`), all are classified | ||
as this `EmoticonNode`. | ||
Whether emoji (`ā¤ļø`), emoticon (`<3`), or gemoji (`:heart:`), all are | ||
classified as `EmoticonNode`s. | ||
```idl | ||
interface EmoticonNode < SymbolNode { | ||
interface Emoticon < Symbol { | ||
type: "EmoticonNode"; | ||
@@ -99,7 +84,35 @@ data: EmoticonData; | ||
**retext-emoji** supports every [wooorm/gemoji](https://github.com/wooorm/gemoji/#supported-gemoji) | ||
and every [wooorm/emoticon](https://github.com/wooorm/emoticon/#supported-emoticon). | ||
**retext-emoji** supports every [`wooorm/gemoji`][gemoji] and every | ||
[`wooorm/emoticon`][emoticon]. | ||
## License | ||
[MIT](LICENSE) Ā© [Titus Wormer](http://wooorm.com) | ||
[MIT][license] Ā© [Titus Wormer][author] | ||
<!-- Definitions --> | ||
[travis-badge]: https://img.shields.io/travis/wooorm/retext-emoji.svg | ||
[travis]: https://travis-ci.org/wooorm/retext-emoji | ||
[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/retext-emoji.svg | ||
[codecov]: https://codecov.io/github/wooorm/retext-emoji | ||
[npm-install]: https://docs.npmjs.com/cli/install | ||
[releases]: https://github.com/wooorm/retext-emoji/releases | ||
[license]: LICENSE | ||
[author]: http://wooorm.com | ||
[retext]: https://github.com/wooorm/retext | ||
[nlcst]: https://github.com/wooorm/nlcst | ||
[symbol]: https://github.com/wooorm/nlcst#symbol | ||
[gemoji]: https://github.com/wooorm/gemoji/#supported-gemoji | ||
[emoticon]: https://github.com/wooorm/emoticon/#supported-emoticon |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
115
12.75%0
-100%8997
-23.29%119
-7.75%- Removed
Updated