Skip to content

Commit 22a6c63

Browse files
committed
Add improved docs
1 parent 8f734d2 commit 22a6c63

File tree

1 file changed

+97
-20
lines changed

1 file changed

+97
-20
lines changed

readme.md

+97-20
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,63 @@
88
[![Backers][backers-badge]][collective]
99
[![Chat][chat-badge]][chat]
1010

11-
[**nlcst**][nlcst] utility to move initial emoticons into the previous sentence.
12-
Useful because many people place an emoticon, representing emotion related to
13-
the previous sentence, after a terminal marker. :unamused:
11+
[nlcst][] utility to move initial emoticons into the previous sentence.
1412

15-
> **Note**: You probably want to use [retext-emoji][].
13+
## Contents
1614

17-
## Install
15+
* [What is this?](#what-is-this)
16+
* [When should I use this?](#when-should-i-use-this)
17+
* [Install](#install)
18+
* [Use](#use)
19+
* [API](#api)
20+
* [`affixEmoticonModifier(paragraph)`](#affixemoticonmodifierparagraph)
21+
* [Types](#types)
22+
* [Compatibility](#compatibility)
23+
* [Related](#related)
24+
* [Contribute](#contribute)
25+
* [License](#license)
26+
27+
## What is this?
28+
29+
This utility searches emoticon nodes (from
30+
[`nlcst-emoticon-modifier`][nlcst-emoticon-modifier] and
31+
[`nlcst-emoji-modifier`][nlcst-emoji-modifier]) that start a sentence and then
32+
moves them into the previous sentence.
33+
34+
## When should I use this?
1835

19-
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
20-
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
36+
This package is a tiny utility that helps when dealing with emoticons in natural
37+
language.
38+
It’s useful because many people place an emoticon or emoji, representing emotion
39+
related to the previous sentence, after a terminal marker.
40+
😒
41+
42+
The plugin [`retext-emoji`][retext-emoji] wraps this utility and others at a
43+
higher-level (easier) abstraction.
44+
45+
## Install
2146

22-
[npm][]:
47+
This package is [ESM only][esm].
48+
In Node.js (version 12.20+, 14.14+, 16.0+, 18.0+), install with [npm][]:
2349

2450
```sh
2551
npm install nlcst-affix-emoticon-modifier
2652
```
2753

54+
In Deno with [`esm.sh`][esmsh]:
55+
56+
```js
57+
import {affixEmoticonModifier} from "https://esm.sh/nlcst-affix-emoticon-modifier@2"
58+
```
59+
60+
In browsers with [`esm.sh`][esmsh]:
61+
62+
```html
63+
<script type="module">
64+
import {affixEmoticonModifier} from "https://esm.sh/nlcst-affix-emoticon-modifier@2?bundle"
65+
</script>
66+
```
67+
2868
## Use
2969

3070
```js
@@ -70,30 +110,55 @@ RootNode[1] (1:1-1:25, 0-24)
70110

71111
## API
72112

73-
This package exports the following identifiers: `affixEmoticonModifier`.
113+
This package exports the identifier `affixEmoticonModifier`.
74114
There is no default export.
75115

76116
### `affixEmoticonModifier(paragraph)`
77117

78-
Merge affix emoticons (`EmoticonNode`) into the previous sentence.
118+
Merge affix emoticons (`EmoticonNode`) in `node` ([`Paragraph`][paragraph]).
79119

80-
##### Parameters
120+
## Types
81121

82-
###### `paragraph`
122+
This package is fully typed with [TypeScript][].
123+
It exports no additional types.
83124

84-
The node to process ([`Paragraph`][paragraph]).
125+
It also registers the `Emoticon` node type with `@types/nlcst`.
126+
If you’re working with the syntax tree, make sure to import this utility
127+
somewhere in your types, as that registers the new node types in the tree.
128+
129+
```js
130+
/**
131+
* @typedef {import('nlcst-affix-emoticon-modifier')}
132+
*/
133+
134+
import {visit} from 'unist-util-visit'
135+
136+
/** @type {import('nlcst').Root} */
137+
const tree = getNodeSomeHow()
138+
139+
visit(tree, (node) => {
140+
// `node` can now be a `Emoticon` node.
141+
})
142+
```
143+
144+
## Compatibility
145+
146+
Projects maintained by the unified collective are compatible with all maintained
147+
versions of Node.js.
148+
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
149+
Our projects sometimes work with older versions, but this is not guaranteed.
85150

86151
## Related
87152

88153
* [`nlcst-emoticon-modifier`](https://github.com/syntax-tree/nlcst-emoticon-modifier)
89-
Support emoticons
154+
support emoticons
90155
* [`nlcst-emoji-modifier`](https://github.com/syntax-tree/nlcst-emoji-modifier)
91-
Support emoji
156+
support emoji and gemoji
92157

93158
## Contribute
94159

95-
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
96-
started.
160+
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
161+
ways to get started.
97162
See [`support.md`][support] for ways to get help.
98163

99164
This project has a [Code of Conduct][coc].
@@ -134,18 +199,30 @@ abide by its terms.
134199

135200
[npm]: https://docs.npmjs.com/cli/install
136201

202+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
203+
204+
[esmsh]: https://esm.sh
205+
206+
[typescript]: https://www.typescriptlang.org
207+
137208
[license]: license
138209

139210
[author]: https://wooorm.com
140211

141-
[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
212+
[health]: https://github.com/syntax-tree/.github
142213

143-
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
214+
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
144215

145-
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
216+
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
217+
218+
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
146219

147220
[retext-emoji]: https://github.com/retextjs/retext-emoji
148221

149222
[nlcst]: https://github.com/syntax-tree/nlcst
150223

151224
[paragraph]: https://github.com/syntax-tree/nlcst#paragraph
225+
226+
[nlcst-emoticon-modifier]: https://github.com/syntax-tree/nlcst-emoticon-modifier
227+
228+
[nlcst-emoji-modifier]: https://github.com/syntax-tree/nlcst-emoji-modifier

0 commit comments

Comments
 (0)