retext-emoji
Advanced tools
Comparing version 0.0.5 to 0.1.0
@@ -5,3 +5,3 @@ { | ||
"description": "Retext implementation of gemojis", | ||
"version": "0.0.5", | ||
"version": "0.1.0", | ||
"keywords": [ | ||
@@ -13,3 +13,3 @@ "retext", | ||
"dependencies": { | ||
"wooorm/gemoji": "^0.0.3" | ||
"wooorm/gemoji": "^0.1.0" | ||
}, | ||
@@ -16,0 +16,0 @@ "scripts" : [ |
122
index.js
@@ -8,2 +8,3 @@ 'use strict'; | ||
names = gemoji.name; | ||
unicode = gemoji.unicode; | ||
shortcodes = gemoji.shortcode = {}; | ||
@@ -15,62 +16,85 @@ | ||
function onchangeFactory(method) { | ||
return function () { | ||
var self = this, | ||
value = self.toString(), | ||
startNode, nodes, iterator, emoticon; | ||
function mergeEmojiExceptions(child, index, parent) { | ||
var siblings = parent.children, | ||
children = child.children, | ||
iterator = index, | ||
childIterator, node, nodes, value, length; | ||
if (value !== ':') { | ||
method(self, value); | ||
if ( | ||
child.type === 'WordNode' && | ||
0 in children && | ||
children[0].value in unicode | ||
) { | ||
parent.children[index] = { | ||
'type' : 'PunctuationNode', | ||
'children' : children | ||
}; | ||
return index - 1; | ||
} | ||
if ( | ||
child.type !== 'PunctuationNode' || | ||
!(0 in children) || | ||
children[0].value !== ':') { | ||
return; | ||
} | ||
nodes = []; | ||
while (siblings[--iterator]) { | ||
node = siblings[iterator]; | ||
nodes = nodes.concat(node.children.reverse()); | ||
if ( | ||
node.type === 'PunctuationNode' && | ||
node.children[0].value === ':' | ||
) { | ||
break; | ||
} | ||
} | ||
startNode = self.prev; | ||
nodes = []; | ||
iterator = -1; | ||
if (iterator === -1) { | ||
return; | ||
} | ||
while (startNode) { | ||
if (startNode.type === startNode.PUNCTUATION_NODE) { | ||
value = startNode.toString(); | ||
nodes = nodes.reverse().concat(children); | ||
if (value === ':') { | ||
emoticon = nodes.reverse().join(''); | ||
childIterator = -1; | ||
length = nodes.length; | ||
value = ''; | ||
if (gemoji.name[emoticon]) { | ||
startNode.remove(); | ||
while (++childIterator < length) { | ||
value += nodes[childIterator].value; | ||
} | ||
while (nodes[++iterator]) { | ||
nodes[iterator].remove(); | ||
} | ||
if (!(value in shortcodes)) { | ||
return; | ||
} | ||
self.fromString(':' + emoticon + ':'); | ||
} | ||
siblings.splice(iterator, index - iterator); | ||
child.children = nodes; | ||
return; | ||
} | ||
// Many gemojis contain underscores, and two contain | ||
// dashes (`:e-mail:` and `:non-potable_water:`). | ||
if (value !== '_' && value !== '-') { | ||
return; | ||
} | ||
} | ||
nodes.push(startNode); | ||
startNode = startNode.prev; | ||
} | ||
}; | ||
return iterator; | ||
} | ||
function encode(node, value) { | ||
value = gemoji.shortcode[value]; | ||
function encode() { | ||
var self = this, | ||
value = shortcodes[self.toString()]; | ||
if (value) { | ||
node.fromString(value); | ||
self.tail.remove(); | ||
self.head.remove(); | ||
self.head.fromString(value); | ||
} | ||
} | ||
function decode(node, value) { | ||
value = gemoji.unicode[value]; | ||
function decode() { | ||
var self = this, | ||
value = unicode[self.toString()]; | ||
if (value) { | ||
node.fromString(':' + value + ':'); | ||
self.head.fromString(value); | ||
self.prepend(new self.TextOM.TextNode(':')); | ||
self.append(new self.TextOM.TextNode(':')); | ||
} | ||
@@ -81,9 +105,13 @@ } | ||
return function (retext) { | ||
var TextOM = retext.parser.TextOM, | ||
onchange = onchangeFactory( | ||
type === 'encode' ? encode : decode | ||
); | ||
var parser = retext.parser, | ||
TextOM = parser.TextOM, | ||
onchange = type === 'encode' ? encode : decode; | ||
TextOM.PunctuationNode.on('changetext', onchange); | ||
TextOM.PunctuationNode.on('changeprev', onchange); | ||
parser.tokenizeSentenceModifiers = [ | ||
mergeEmojiExceptions | ||
].concat(parser.tokenizeSentenceModifiers); | ||
TextOM.PunctuationNode.on('changetextinside', onchange); | ||
TextOM.PunctuationNode.on('insertinside', onchange); | ||
TextOM.PunctuationNode.on('removeinside', onchange); | ||
}; | ||
@@ -90,0 +118,0 @@ } |
{ | ||
"name": "retext-emoji", | ||
"version": "0.0.5", | ||
"version": "0.1.0", | ||
"description": "Retext implementation of gemojis", | ||
@@ -13,13 +13,12 @@ "keywords": [ | ||
"devDependencies": { | ||
"browserify": "^4.1.11", | ||
"eslint": "^0.6.2", | ||
"istanbul": "~0.2.11", | ||
"eslint": "^0.7.4", | ||
"istanbul": "~0.3.0", | ||
"jscs": "^1.5.3", | ||
"mocha": "~1.20.1", | ||
"retext": "~0.0.12", | ||
"retext-ast": "~0.0.3", | ||
"retext-content": "~0.0.3" | ||
"retext": "^0.1.0-rc.4", | ||
"retext-ast": "^0.1.0", | ||
"retext-content": "^0.1.1" | ||
}, | ||
"dependencies": { | ||
"gemoji": "~0.0.3" | ||
"gemoji": "^0.1.0" | ||
}, | ||
@@ -34,9 +33,7 @@ "repository": { | ||
"lint": "npm run-script lint-api && npm run-script lint-test && npm run-script lint-style", | ||
"lint-api": "node_modules/.bin/eslint index.js --env node --env browser --rule 'quotes: [2, single]'", | ||
"lint-api": "node_modules/.bin/eslint index.js --env node --env browser --rule 'quotes: [2, single], consistent-return: false'", | ||
"lint-test": "node_modules/.bin/eslint spec/retext-emoji.spec.js --env node --env mocha --rule 'quotes: [2, single], no-loop-func: false'", | ||
"lint-style": "node_modules/.bin/jscs index.js spec/retext-emoji.spec.js --reporter=inline", | ||
"prepublish": "npm run-script build-browser", | ||
"build-browser": "node_modules/.bin/browserify spec/retext-emoji.spec.js -o spec/browser.spec.js", | ||
"coverage": "node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- -- spec/retext-emoji.spec.js", | ||
"make": "npm run-script build-browser && npm run-script lint && npm run-script coverage" | ||
"make": "npm run-script lint && npm run-script coverage" | ||
}, | ||
@@ -43,0 +40,0 @@ "testling": { |
@@ -32,3 +32,3 @@ # retext-emoji [](https://travis-ci.org/wooorm/retext-emoji) [](https://coveralls.io/r/wooorm/retext-emoji?branch=master) | ||
var text = new Retext() | ||
new Retext() | ||
.use(emoji({ | ||
@@ -44,4 +44,7 @@ 'convert' : 'encode' | ||
- When `encode`, converts short-codes into their unicode equivalent (e.g., `:pig:` to `🐷`); | ||
- When `decode`, converts unicode emojis into their short-code equivalent (e.g., `🐷` to `:pig:`); | ||
- When `decode`, converts unicode emoji into their short-code equivalent (e.g., `🐷` to `:pig:`); | ||
## Supported Gemoji | ||
retext-emoji should support every gemoji [wooorm/gemoji](https://github.com/wooorm/gemoji) supports. There's a whole list of supported gemoji at [gemoji's repo](https://github.com/wooorm/gemoji/#supported-gemoji). | ||
## Browser Support | ||
@@ -48,0 +51,0 @@ Pretty much every browser (available through browserstack) runs all retext-emoji unit tests. |
'use strict'; | ||
var emoji, gemoji, Retext, AST, content, assert, fs, baseSentence, | ||
fullStop, encodeRetext, decodeRetext, names, name, unicode, unsupported, | ||
iterator; | ||
var emoji, gemoji, Retext, AST, content, assert, baseSentence, | ||
fullStop, encodeRetext, decodeRetext, name, unicode; | ||
@@ -70,5 +69,6 @@ emoji = require('..'); | ||
it('should classify gemojis (e.g., `:sob:`) as a single punctuation node', | ||
it('should classify gemoji (e.g., `:sob:`) as a single punctuation node', | ||
function () { | ||
var tree = decodeRetext.parse('This makes me feel :sob:.'); | ||
assert(tree.head.head.toAST() === JSON.stringify({ | ||
@@ -79,39 +79,97 @@ 'type' : 'SentenceNode', | ||
'type' : 'WordNode', | ||
'value' : 'This' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'This' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'makes' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'makes' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'me' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'me' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'feel' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'feel' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : ':sob:' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ':' | ||
}, | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'sob' | ||
}, | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ':' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : '.' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : '.' | ||
} | ||
] | ||
} | ||
@@ -123,6 +181,6 @@ ] | ||
it('should classify gemojis (e.g., `:sob:`) as a single punctuation ' + | ||
it('should classify gemoji (e.g., `:sob:`) as a single punctuation ' + | ||
'node, when inserted after the initial parse', function () { | ||
var tree = decodeRetext.parse('This makes me feel '); | ||
tree.head.head.appendContent(':sob:.'); | ||
var tree = decodeRetext.parse('This makes me feel'); | ||
tree.head.head.appendContent(' :sob:.'); | ||
assert(tree.head.head.toAST() === JSON.stringify({ | ||
@@ -133,39 +191,97 @@ 'type' : 'SentenceNode', | ||
'type' : 'WordNode', | ||
'value' : 'This' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'This' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'makes' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'makes' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'me' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'me' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'feel' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'feel' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : ':sob:' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ':' | ||
}, | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'sob' | ||
}, | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ':' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : '.' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : '.' | ||
} | ||
] | ||
} | ||
@@ -177,3 +293,3 @@ ] | ||
it('should NOT classify invalid gemoji-like sequences as gemojis ' + | ||
it('should NOT classify invalid gemoji-like sequences as gemoji ' + | ||
'(e.g., `:trololol:`) as a single punctuation node', function () { | ||
@@ -186,47 +302,107 @@ var tree = decodeRetext.parse('This makes me feel :trololol:.'); | ||
'type' : 'WordNode', | ||
'value' : 'This' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'This' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'makes' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'makes' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'me' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'me' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'feel' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'feel' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : ':' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ':' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'trololol' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'trololol' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : ':' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ':' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : '.' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : '.' | ||
} | ||
] | ||
} | ||
@@ -236,3 +412,4 @@ ] | ||
tree = decodeRetext.parse('Hello Mr. Smith:\n'); | ||
tree = decodeRetext.parse('Hello L.L. Smith:\n'); | ||
assert(tree.head.head.toAST() === JSON.stringify({ | ||
@@ -243,27 +420,75 @@ 'type' : 'SentenceNode', | ||
'type' : 'WordNode', | ||
'value' : 'Hello' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'Hello' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'Mr' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'L' | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : '.' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'L' | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : '.' | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : '.' | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'Smith' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'Smith' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : ':' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ':' | ||
} | ||
] | ||
} | ||
@@ -275,3 +500,3 @@ ] | ||
it('should automatically convert gemojis (e.g., `:sob:`) to their ' + | ||
it('should automatically convert gemoji (e.g., `:sob:`) to their ' + | ||
'unicode equivalent, when `convert` is `encode`', function () { | ||
@@ -284,39 +509,89 @@ var tree = encodeRetext.parse('This makes me feel :sob:.'); | ||
'type' : 'WordNode', | ||
'value' : 'This' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'This' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'makes' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'makes' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'me' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'me' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'feel' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'feel' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : '\uD83D\uDE2D' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : '\uD83D\uDE2D' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : '.' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : '.' | ||
} | ||
] | ||
} | ||
@@ -328,7 +603,7 @@ ] | ||
it('should automatically convert gemojis (e.g., `:sob:`) to their ' + | ||
it('should automatically convert gemoji (e.g., `:sob:`) to their ' + | ||
'unicode equivalent, when inserted after the initial parse and ' + | ||
'`convert` is `encode`', function () { | ||
var tree = encodeRetext.parse('This makes me feel '); | ||
tree.head.head.appendContent(':sob:.'); | ||
var tree = encodeRetext.parse('This makes me feel'); | ||
tree.head.head.appendContent(' :sob:.'); | ||
assert(tree.head.head.toAST() === JSON.stringify({ | ||
@@ -339,39 +614,89 @@ 'type' : 'SentenceNode', | ||
'type' : 'WordNode', | ||
'value' : 'This' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'This' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'makes' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'makes' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'me' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'me' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'feel' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'feel' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : '\uD83D\uDE2D' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : '\uD83D\uDE2D' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : '.' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : '.' | ||
} | ||
] | ||
} | ||
@@ -383,3 +708,3 @@ ] | ||
it('should automatically convert emojis (e.g., `\uD83D\uDE2D`) to ' + | ||
it('should automatically convert emoji (e.g., `\uD83D\uDE2D`) to ' + | ||
'their gemoji equivalent, when `convert` is `decode`', function () { | ||
@@ -392,39 +717,97 @@ var tree = decodeRetext.parse('This makes me feel \uD83D\uDE2D.'); | ||
'type' : 'WordNode', | ||
'value' : 'This' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'This' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'makes' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'makes' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'me' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'me' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'feel' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'feel' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : ':sob:' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ':' | ||
}, | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'sob' | ||
}, | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ':' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : '.' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : '.' | ||
} | ||
] | ||
} | ||
@@ -436,7 +819,7 @@ ] | ||
it('should automatically convert emojis (e.g., `\uD83D\uDE2D`) to ' + | ||
it('should automatically convert emoji (e.g., `\uD83D\uDE2D`) to ' + | ||
'their gemoji equivalent, when inserted after the initial parse ' + | ||
'and `convert` is `decode`', function () { | ||
var tree = decodeRetext.parse('This makes me feel '); | ||
tree.head.head.appendContent('\uD83D\uDE2D.'); | ||
var tree = decodeRetext.parse('This makes me feel'); | ||
tree.head.head.appendContent(' \uD83D\uDE2D.'); | ||
assert(tree.head.head.toAST() === JSON.stringify({ | ||
@@ -447,39 +830,97 @@ 'type' : 'SentenceNode', | ||
'type' : 'WordNode', | ||
'value' : 'This' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'This' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'makes' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'makes' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'me' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'me' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WordNode', | ||
'value' : 'feel' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'feel' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'WhiteSpaceNode', | ||
'value' : ' ' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ' ' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : ':sob:' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ':' | ||
}, | ||
{ | ||
'type' : 'TextNode', | ||
'value' : 'sob' | ||
}, | ||
{ | ||
'type' : 'TextNode', | ||
'value' : ':' | ||
} | ||
] | ||
}, | ||
{ | ||
'type' : 'PunctuationNode', | ||
'value' : '.' | ||
'children' : [ | ||
{ | ||
'type' : 'TextNode', | ||
'value' : '.' | ||
} | ||
] | ||
} | ||
@@ -492,14 +933,4 @@ ] | ||
names = gemoji.name; | ||
// Delete unsupported gemoji. | ||
unsupported = ['m', 'information_source']; | ||
iterator = -1; | ||
while (unsupported[++iterator]) { | ||
delete names[unsupported[iterator]]; | ||
} | ||
for (name in names) { | ||
unicode = names[name]; | ||
for (name in gemoji.name) { | ||
unicode = gemoji.name[name]; | ||
name = ':' + name + ':'; | ||
@@ -506,0 +937,0 @@ |
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
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
7
54
0
48269
1184
+ Addedgemoji@0.1.2(transitive)
- Removedgemoji@0.0.3(transitive)
Updatedgemoji@^0.1.0