unified

Project:syntax-tree/nlcst-emoji-modifier

Package:nlcst-emoji-modifier@4.0.0

  1. Dependencies:6·Dependents:2
  2. nlcst utility to support emoji
  1. util 105
  2. utility 105
  3. unist 90
  4. nlcst 13
  5. nlcst-util 8
  6. emoji 5
  7. emoticon 4

nlcst-emoji-modifier

Build Coverage Downloads Size Sponsors Backers Chat

nlcst utility to classify emoji and gemoji shortcodes as EmoticonNodes.

Note: You probably want to use retext-emoji.

Install

npm:

npm install nlcst-emoji-modifier

Use

var modifier = require('nlcst-emoji-modifier')
var inspect = require('unist-util-inspect')
var english = require('parse-english')()

english.useFirst('tokenizeSentence', modifier)

console.log(inspect(english.parse('It’s raining :cat:s and :dog:s.')))

Yields:

RootNode[1] (1:1-1:32, 0-31)
└─ ParagraphNode[1] (1:1-1:32, 0-31)
   └─ SentenceNode[11] (1:1-1:32, 0-31)
      ├─ WordNode[3] (1:1-1:5, 0-4)
      │  ├─ TextNode: "It" (1:1-1:3, 0-2)
      │  ├─ PunctuationNode: "’" (1:3-1:4, 2-3)
      │  └─ TextNode: "s" (1:4-1:5, 3-4)
      ├─ WhiteSpaceNode: " " (1:5-1:6, 4-5)
      ├─ WordNode[1] (1:6-1:13, 5-12)
      │  └─ TextNode: "raining" (1:6-1:13, 5-12)
      ├─ WhiteSpaceNode: " " (1:13-1:14, 12-13)
      ├─ EmoticonNode: ":cat:" (1:14-1:19, 13-18)
      ├─ WordNode[1] (1:19-1:20, 18-19)
      │  └─ TextNode: "s" (1:19-1:20, 18-19)
      ├─ WhiteSpaceNode: " " (1:20-1:21, 19-20)
      ├─ WordNode[1] (1:21-1:24, 20-23)
      │  └─ TextNode: "and" (1:21-1:24, 20-23)
      ├─ WhiteSpaceNode: " " (1:24-1:25, 23-24)
      ├─ EmoticonNode: ":dog:" (1:25-1:30, 24-29)
      └─ WordNode[2] (1:30-1:32, 29-31)
         ├─ TextNode: "s" (1:30-1:31, 29-30)
         └─ PunctuationNode: "." (1:31-1:32, 30-31)

API

emoji(node)

Merge emoji and gemoji into a new EmoticonNode.

Parameters

Contribute

See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer