Skip to content

Commit 93a740b

Browse files
committed
Add improved docs
1 parent da5589f commit 93a740b

File tree

1 file changed

+72
-18
lines changed

1 file changed

+72
-18
lines changed

readme.md

Lines changed: 72 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,60 @@
88
[![Backers][backers-badge]][collective]
99
[![Chat][chat-badge]][chat]
1010

11-
[**nlcst**][nlcst] utility to check if a node is meant literally.
11+
[nlcst][] utility to check if a node is meant literally.
1212

13-
Useful if a tool wants to exclude values that are possibly void of meaning.
13+
## Contents
14+
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+
* [`isLiteral(parent, index|child)`](#isliteralparent-indexchild)
21+
* [Types](#types)
22+
* [Compatibility](#compatibility)
23+
* [Related](#related)
24+
* [Contribute](#contribute)
25+
* [License](#license)
26+
27+
## What is this?
28+
29+
This utility can check if a node is meant literally.
30+
31+
## When should I use this?
32+
33+
This package is a tiny utility that helps when dealing with words.
34+
It’s useful if a tool wants to exclude values that are possibly void of
35+
meaning.
1436
For example, a spell-checker could exclude these literal words, thus not warning
1537
about “monsieur”.
1638

1739
## Install
1840

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.
21-
22-
[npm][]:
41+
This package is [ESM only][esm].
42+
In Node.js (version 12.20+, 14.14+, 16.0+, 18.0+), install with [npm][]:
2343

2444
```sh
2545
npm install nlcst-is-literal
2646
```
2747

48+
In Deno with [`esm.sh`][esmsh]:
49+
50+
```js
51+
import {isLiteral} from "https://esm.sh/nlcst-is-literal@2"
52+
```
53+
54+
In browsers with [`esm.sh`][esmsh]:
55+
56+
```html
57+
<script type="module">
58+
import {isLiteral} from "https://esm.sh/nlcst-is-literal@2?bundle"
59+
</script>
60+
```
61+
2862
## Use
2963

30-
Say we have the following file, `example.txt`:
64+
Say our document `example.txt` contains:
3165

3266
```txt
3367
The word “foo” is meant as a literal.
@@ -41,7 +75,7 @@ The word, qux, is meant as a literal.
4175
The word — quux — is meant as a literal.
4276
```
4377

44-
And our script, `example.js`, looks as follows:
78+
…and our module `example.js` looks as follows:
4579

4680
```js
4781
import {readSync} from 'to-vfile'
@@ -64,7 +98,7 @@ function visitor(node, index, parent) {
6498
}
6599
```
66100

67-
Now, running `node example` yields:
101+
…now running `node example.js` yields:
68102

69103
```txt
70104
foo
@@ -76,31 +110,43 @@ quux
76110

77111
## API
78112

79-
This package exports the following identifiers: `isLiteral`.
113+
This package exports the identifier `isLiteral`.
80114
There is no default export.
81115

82116
### `isLiteral(parent, index|child)`
83117

84118
Check if the `child` in `parent` is enclosed by matching delimiters.
85-
If `index` is given, the [child][] of `parent` at that [index][] is checked.
119+
If an `index` is given, the [child][] of `parent` at that [index][] is checked.
86120

87121
For example, `foo` is literal in the following samples:
88122

89123
* `Foo - is meant as a literal.`
90124
* `Meant as a literal is - foo.`
91125
* `The word “foo” is meant as a literal.`
92126

127+
## Types
128+
129+
This package is fully typed with [TypeScript][].
130+
It exports no additional types.
131+
132+
## Compatibility
133+
134+
Projects maintained by the unified collective are compatible with all maintained
135+
versions of Node.js.
136+
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
137+
Our projects sometimes work with older versions, but this is not guaranteed.
138+
93139
## Related
94140

95141
* [`nlcst-normalize`](https://github.com/syntax-tree/nlcst-normalize)
96-
Normalize a word for easier comparison
142+
normalize a word for easier comparison
97143
* [`nlcst-search`](https://github.com/syntax-tree/nlcst-search)
98-
Search for patterns
144+
search for patterns
99145

100146
## Contribute
101147

102-
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
103-
started.
148+
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
149+
ways to get started.
104150
See [`support.md`][support] for ways to get help.
105151

106152
This project has a [code of conduct][coc].
@@ -141,15 +187,23 @@ abide by its terms.
141187

142188
[npm]: https://docs.npmjs.com/cli/install
143189

190+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
191+
192+
[esmsh]: https://esm.sh
193+
194+
[typescript]: https://www.typescriptlang.org
195+
144196
[license]: license
145197

146198
[author]: https://wooorm.com
147199

148-
[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
200+
[health]: https://github.com/syntax-tree/.github
201+
202+
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
149203

150-
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
204+
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
151205

152-
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
206+
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
153207

154208
[nlcst]: https://github.com/syntax-tree/nlcst
155209

0 commit comments

Comments
 (0)