Skip to content

Commit 1758142

Browse files
committed
Refactor prose
1 parent bf6b972 commit 1758142

File tree

1 file changed

+68
-43
lines changed

1 file changed

+68
-43
lines changed

readme.md

Lines changed: 68 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
# hast-util-to-nlcst [![Build][build-badge]][build] [![Coverage][coverage-badge]][coverage] [![Downloads][downloads-badge]][downloads] [![Chat][chat-badge]][chat]
1+
# hast-util-to-nlcst
22

3-
Transform [HAST][] to [NLCST][].
3+
[![Build][build-badge]][build]
4+
[![Coverage][coverage-badge]][coverage]
5+
[![Downloads][downloads-badge]][downloads]
6+
[![Size][size-badge]][size]
7+
[![Sponsors][sponsors-badge]][collective]
8+
[![Backers][backers-badge]][collective]
9+
[![Chat][chat-badge]][chat]
410

5-
> **Note**: You probably want to use [rehype-retext][].
11+
[**hast**][hast] utility to transform to [**nlcst**][nlcst].
612

7-
## Installation
13+
> **Note**: You probably want to use [`rehype-retext`][rehype-retext].
14+
15+
## Install
816

917
[npm][]:
1018

11-
```bash
19+
```sh
1220
npm install hast-util-to-nlcst
1321
```
1422

@@ -24,9 +32,9 @@ Say we have the following `example.html`:
2432
</article>
2533
```
2634

27-
...and next to it, `index.js`:
35+
and next to it, `index.js`:
2836

29-
```javascript
37+
```js
3038
var rehype = require('rehype')
3139
var vfile = require('to-vfile')
3240
var English = require('parse-english')
@@ -65,50 +73,45 @@ RootNode[2] (1:1-6:1, 0-134)
6573

6674
## API
6775

68-
### `toNLCST(node, file, Parser)`
76+
### `toNlcst(tree, file, Parser)`
6977

70-
Transform a [HAST][] syntax tree and corresponding [virtual file][vfile]
71-
into an [NLCST][nlcst] tree.
78+
Transform the given [**hast**][hast] [*tree*][tree] to [**nlcst**][nlcst].
7279

7380
##### Parameters
7481

75-
###### `node`
76-
77-
Syntax tree with positional information ([`HASTNode`][hast]).
78-
79-
###### `file`
80-
81-
Virtual file ([`VFile`][vfile]).
82-
83-
###### `parser`
84-
85-
Constructor of an NLCST parser, such as [`parse-english`][english],
86-
[`parse-dutch`][dutch], or [`parse-latin`][latin] (`Function`).
82+
* `tree` ([`HastNode`][hast-node])
83+
[*Tree*][tree] with [positional info][positional-information]
84+
([`HastNode`][hast-node])
85+
* `file` ([`VFile`][vfile])
86+
— Virtual file
87+
* `parser` (`Function`)
88+
[**nlcst**][nlcst] parser, such as [`parse-english`][english],
89+
[`parse-dutch`][dutch], or [`parse-latin`][latin]
8790

8891
##### Returns
8992

90-
[`NLCSTNode`][nlcst].
93+
[`NlcstNode`][nlcst-node].
9194

9295
##### Notes
9396

94-
###### Implied sentences
97+
###### Implied paragraphs
9598

9699
The algorithm supports implicit and explicit paragraphs, such as:
97100

98101
```html
99102
<article>
100-
An implicit sentence.
101-
<h1>An explicit sentence.</h1>
103+
An implicit paragraph.
104+
<h1>An explicit paragraph.</h1>
102105
</article>
103106
```
104107

105-
Overlapping paragraphs are also supported (see the tests or the HTML spec
106-
for more info).
108+
Overlapping paragraphs are also supported (see the tests or the HTML spec for
109+
more info).
107110

108111
###### Ignored nodes
109112

110-
Some elements are ignored and their content will not be present in NLCST:
111-
`<script>`, `<style>`, `<svg>`, `<math>`, `<del>`.
113+
Some elements are ignored and their content will not be present in
114+
[**nlcst**][nlcst]: `<script>`, `<style>`, `<svg>`, `<math>`, `<del>`.
112115

113116
To ignore other elements, add a `data-nlcst` attribute with a value of `ignore`:
114117

@@ -119,7 +122,7 @@ To ignore other elements, add a `data-nlcst` attribute with a value of `ignore`:
119122

120123
###### Source nodes
121124

122-
`<code>` elements are mapped to [Source][] nodes in NLCST.
125+
`<code>` elements are mapped to [`Source`][source] nodes in [**nlcst**][nlcst].
123126

124127
To mark other elements as source, add a `data-nlcst` attribute with a value
125128
of `source`:
@@ -131,11 +134,13 @@ of `source`:
131134

132135
## Contribute
133136

134-
See [`contributing.md` in `syntax-tree/hast`][contributing] for ways to get
137+
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
135138
started.
139+
See [`support.md`][support] for ways to get help.
136140

137-
This organisation has a [Code of Conduct][coc]. By interacting with this
138-
repository, organisation, or community you agree to abide by its terms.
141+
This project has a [Code of Conduct][coc].
142+
By interacting with this repository, organisation, or community you agree to
143+
abide by its terms.
139144

140145
## License
141146

@@ -155,32 +160,52 @@ repository, organisation, or community you agree to abide by its terms.
155160

156161
[downloads]: https://www.npmjs.com/package/hast-util-to-nlcst
157162

163+
[size-badge]: https://img.shields.io/bundlephobia/minzip/hast-util-to-nlcst.svg
164+
165+
[size]: https://bundlephobia.com/result?p=hast-util-to-nlcst
166+
167+
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
168+
169+
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
170+
171+
[collective]: https://opencollective.com/unified
172+
158173
[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
159174

160-
[chat]: https://spectrum.chat/unified/rehype
175+
[chat]: https://spectrum.chat/unified/syntax-tree
161176

162177
[npm]: https://docs.npmjs.com/cli/install
163178

164179
[license]: license
165180

166181
[author]: https://wooorm.com
167182

168-
[hast]: https://github.com/syntax-tree/hast
169-
170-
[nlcst]: https://github.com/syntax-tree/nlcst
183+
[contributing]: https://github.com/syntax-tree/.github/blob/master/contributing.md
171184

172-
[rehype-retext]: https://github.com/rehypejs/rehype-retext
185+
[support]: https://github.com/syntax-tree/.github/blob/master/support.md
173186

174-
[vfile]: https://github.com/vfile/vfile
187+
[coc]: https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
175188

176189
[english]: https://github.com/wooorm/parse-english
177190

178191
[latin]: https://github.com/wooorm/parse-latin
179192

180193
[dutch]: https://github.com/wooorm/parse-dutch
181194

182-
[source]: https://github.com/syntax-tree/nlcst#source
195+
[rehype-retext]: https://github.com/rehypejs/rehype-retext
196+
197+
[tree]: https://github.com/syntax-tree/unist#tree
198+
199+
[positional-information]: https://github.com/syntax-tree/unist#positional-information
200+
201+
[hast]: https://github.com/syntax-tree/hast
202+
203+
[hast-node]: https://github.com/syntax-tree/hast#nodes
204+
205+
[nlcst]: https://github.com/syntax-tree/nlcst
183206

184-
[contributing]: https://github.com/syntax-tree/hast/blob/master/contributing.md
207+
[nlcst-node]: https://github.com/syntax-tree/nlcst#nodes
185208

186-
[coc]: https://github.com/syntax-tree/hast/blob/master/code-of-conduct.md
209+
[vfile]: https://github.com/vfile/vfile
210+
211+
[source]: https://github.com/syntax-tree/nlcst#source

0 commit comments

Comments
 (0)