Skip to content

Commit c77ccb8

Browse files
committed
Refactor prose
1 parent 984a3a7 commit c77ccb8

File tree

1 file changed

+53
-21
lines changed

1 file changed

+53
-21
lines changed

readme.md

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,30 @@
33
[![Build][build-badge]][build]
44
[![Coverage][coverage-badge]][coverage]
55
[![Downloads][downloads-badge]][downloads]
6+
[![Size][size-badge]][size]
7+
[![Sponsors][sponsors-badge]][collective]
8+
[![Backers][backers-badge]][collective]
69
[![Chat][chat-badge]][chat]
710

8-
Set the plain-text value of a [hast][] node.
11+
[**hast**][hast] utility to get the plain-text value of a [*node*][node].
12+
913
This is like the DOMs `Node#innerText` setter.
10-
The given node is returned.
1114

1215
You’d typically want to use [`hast-util-from-string`][from-string]
1316
(`textContent`), but `hast-util-from-text` (`innerText`) adds `<br>` elements
1417
instead of line breaks.
1518

16-
## Installation
19+
## Install
1720

1821
[npm][]:
1922

20-
```bash
23+
```sh
2124
npm install hast-util-from-text
2225
```
2326

2427
## Usage
2528

26-
```javascript
29+
```js
2730
var h = require('hastscript')
2831
var fromText = require('hast-util-from-text')
2932

@@ -53,28 +56,33 @@ fromText(h('p'), 'Delta\nEcho')
5356

5457
### `fromText(node[, value])`
5558

56-
If `node` is a literal (has a `value` property), set that to the given `value`
57-
or an empty string.
58-
If `node` is a parent node (has `children`), its children are replaced with new
59-
children: text nodes for every run of text and `<br>` elements for every line
60-
break (`\n`, `\r`, or `\r\n`).
61-
If no `value` is given (empty string `''`, `null`, or `undefined`), all
62-
children are removed.
59+
If the given `node` is a [*literal*][literal], set that to the given `value` or
60+
an empty string.
61+
If the given `node` is a [*parent*][parent], its [*children*][child] are
62+
replaced with new children: [*texts*][text] for every run of text and `<br>`
63+
[*elements*][element] for every line break (a line feed, `\n`; a carriage
64+
return, `\r`; or a carriage return + line feed, `\r\n`).
65+
If no `value` is given (empty string `''`, `null`, or `undefined`), the
66+
literal’s value is set to an empty string or the parent’s children are removed.
6367

6468
## Related
6569

66-
* [`hast-util-from-string`](https://github.com/rehypejs/rehype-minify/tree/master/packages/hast-util-from-string)
67-
Set the plain-text value (`textContent`)
70+
* [`hast-util-to-text`](https://github.com/syntax-tree/hast-util-to-text)
71+
Get the plain-text value (`innerText`)
6872
* [`hast-util-to-string`](https://github.com/rehypejs/rehype-minify/tree/master/packages/hast-util-to-string)
6973
— Get the plain-text value (`textContent`)
74+
* [`hast-util-from-string`][from-string]
75+
— Set the plain-text value (`textContent`)
7076

7177
## Contribute
7278

73-
See [`contributing.md` in `syntax-tree/hast`][contributing] for ways to get
79+
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
7480
started.
81+
See [`support.md`][support] for ways to get help.
7582

76-
This organisation has a [Code of Conduct][coc]. By interacting with this
77-
repository, organisation, or community you agree to abide by its terms.
83+
This project has a [Code of Conduct][coc].
84+
By interacting with this repository, organisation, or community you agree to
85+
abide by its terms.
7886

7987
## License
8088

@@ -94,20 +102,44 @@ repository, organisation, or community you agree to abide by its terms.
94102

95103
[downloads]: https://www.npmjs.com/package/hast-util-from-text
96104

105+
[size-badge]: https://img.shields.io/bundlephobia/minzip/hast-util-from-text.svg
106+
107+
[size]: https://bundlephobia.com/result?p=hast-util-from-text
108+
109+
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
110+
111+
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
112+
113+
[collective]: https://opencollective.com/unified
114+
97115
[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
98116

99-
[chat]: https://spectrum.chat/unified/rehype
117+
[chat]: https://spectrum.chat/unified/syntax-tree
100118

101119
[npm]: https://docs.npmjs.com/cli/install
102120

103121
[license]: license
104122

105123
[author]: https://wooorm.com
106124

107-
[hast]: https://github.com/syntax-tree/hast
125+
[contributing]: https://github.com/syntax-tree/.github/blob/master/contributing.md
108126

109-
[contributing]: https://github.com/syntax-tree/hast/blob/master/contributing.md
127+
[support]: https://github.com/syntax-tree/.github/blob/master/support.md
110128

111-
[coc]: https://github.com/syntax-tree/hast/blob/master/code-of-conduct.md
129+
[coc]: https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
112130

113131
[from-string]: https://github.com/rehypejs/rehype-minify/tree/master/packages/hast-util-from-string
132+
133+
[literal]: https://github.com/syntax-tree/unist#literal
134+
135+
[parent]: https://github.com/syntax-tree/unist#parent
136+
137+
[child]: https://github.com/syntax-tree/unist#child
138+
139+
[hast]: https://github.com/syntax-tree/hast
140+
141+
[node]: https://github.com/syntax-tree/hast#nodes
142+
143+
[text]: https://github.com/syntax-tree/hast#text
144+
145+
[element]: https://github.com/syntax-tree/hast#element

0 commit comments

Comments
 (0)