Skip to content

Commit 3f15984

Browse files
committed
Refactor prose
1 parent a3484bc commit 3f15984

File tree

1 file changed

+59
-30
lines changed

1 file changed

+59
-30
lines changed

readme.md

Lines changed: 59 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
# hast-util-from-parse5 [![Build][build-badge]][build] [![Coverage][coverage-badge]][coverage] [![Downloads][downloads-badge]][downloads] [![Chat][chat-badge]][chat]
1+
# hast-util-from-parse5
22

3-
Transform [Parse5’s AST][ast] to [HAST][].
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-
## Installation
11+
[**hast**][hast] utility to transform [Parse5’s AST][ast] to a hast
12+
[*tree*][tree].
13+
14+
## Install
615

716
[npm][]:
817

9-
```bash
18+
```sh
1019
npm install hast-util-from-parse5
1120
```
1221

@@ -20,7 +29,7 @@ Say we have the following file, `example.html`:
2029

2130
And our script, `example.js`, looks as follows:
2231

23-
```javascript
32+
```js
2433
var vfile = require('to-vfile')
2534
var parse5 = require('parse5')
2635
var inspect = require('unist-util-inspect')
@@ -53,31 +62,33 @@ root[2] (1:1-2:1, 0-70) [data={"quirksMode":false}]
5362

5463
### `fromParse5(ast[, options])`
5564

56-
Transform an `ASTNode` to a [HAST Node][node].
65+
Transform [Parse5’s AST][ast] to a [**hast**][hast] [*tree*][tree].
5766

5867
##### `options`
5968

60-
If `options` is a [VFile][], it’s treated as `{file: options}`.
69+
If `options` is a [`VFile`][vfile], it’s treated as `{file: options}`.
6170

6271
###### `options.space`
6372

64-
Whether the root of the given tree is in the `'html'` or `'svg'` space (enum,
65-
`'svg'` or `'html'`, default: `'html'`).
73+
Whether the [*root*][root] of the [*tree*][tree] is in the `'html'` or `'svg'`
74+
space (enum, `'svg'` or `'html'`, default: `'html'`).
6675

6776
If an element in with the SVG namespace is found in `ast`, `fromParse5`
68-
automatically switches to the SVG space when entering the element, and
69-
switches back when leaving.
77+
automatically switches to the SVG space when entering the element, and switches
78+
back when leaving.
7079

7180
###### `options.file`
7281

73-
[Virtual file][vfile], used to add positional information to HAST nodes.
74-
If given, the file should have the original HTML source as its contents.
82+
[`VFile`][vfile], used to add [positional information][positional-information]
83+
to [*nodes*][node].
84+
If given, the [*file*][file] should have the original HTML source as its
85+
contents.
7586

7687
###### `options.verbose`
7788

78-
Whether to add positional information about starting tags, closing tags,
79-
and attributes to elements (`boolean`, default: `false`). Note: not used
80-
without `file`.
89+
Whether to add extra positional information about starting tags, closing tags,
90+
and attributes to elements (`boolean`, default: `false`).
91+
Note: not used without `file`.
8192

8293
For the following HTML:
8394

@@ -91,11 +102,7 @@ The verbose info would looks as follows:
91102
{
92103
type: 'element',
93104
tagName: 'img',
94-
properties: {
95-
src: 'http://example.com/fav.ico',
96-
alt: 'foo',
97-
title: 'bar'
98-
},
105+
properties: {src: 'http://example.com/fav.ico', alt: 'foo', title: 'bar'},
99106
children: [],
100107
data: {
101108
position: {
@@ -129,11 +136,13 @@ The verbose info would looks as follows:
129136

130137
## Contribute
131138

132-
See [`contributing.md` in `syntax-tree/hast`][contributing] for ways to get
139+
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
133140
started.
141+
See [`support.md`][support] for ways to get help.
134142

135-
This organisation has a [Code of Conduct][coc]. By interacting with this
136-
repository, organisation, or community you agree to abide by its terms.
143+
This project has a [Code of Conduct][coc].
144+
By interacting with this repository, organisation, or community you agree to
145+
abide by its terms.
137146

138147
## License
139148

@@ -153,24 +162,44 @@ repository, organisation, or community you agree to abide by its terms.
153162

154163
[downloads]: https://www.npmjs.com/package/hast-util-from-parse5
155164

165+
[size-badge]: https://img.shields.io/bundlephobia/minzip/hast-util-from-parse5.svg
166+
167+
[size]: https://bundlephobia.com/result?p=hast-util-from-parse5
168+
169+
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
170+
171+
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
172+
173+
[collective]: https://opencollective.com/unified
174+
156175
[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
157176

158-
[chat]: https://spectrum.chat/unified/rehype
177+
[chat]: https://spectrum.chat/unified/syntax-tree
159178

160179
[npm]: https://docs.npmjs.com/cli/install
161180

162181
[license]: license
163182

164183
[author]: https://wooorm.com
165184

166-
[hast]: https://github.com/syntax-tree/hast
185+
[contributing]: https://github.com/syntax-tree/.github/blob/master/contributing.md
167186

168-
[ast]: https://github.com/inikulin/parse5/blob/master/packages/parse5/docs/tree-adapter/default/interface-list.md
187+
[support]: https://github.com/syntax-tree/.github/blob/master/support.md
188+
189+
[coc]: https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
169190

170-
[node]: https://github.com/syntax-tree/hast#ast
191+
[ast]: https://github.com/inikulin/parse5/blob/master/packages/parse5/docs/tree-adapter/default/interface-list.md
171192

172193
[vfile]: https://github.com/vfile/vfile
173194

174-
[contributing]: https://github.com/syntax-tree/hast/blob/master/contributing.md
195+
[tree]: https://github.com/syntax-tree/unist#tree
196+
197+
[root]: https://github.com/syntax-tree/unist#root
198+
199+
[positional-information]: https://github.com/syntax-tree/unist#positional-information
200+
201+
[file]: https://github.com/syntax-tree/unist#file
202+
203+
[hast]: https://github.com/syntax-tree/hast
175204

176-
[coc]: https://github.com/syntax-tree/hast/blob/master/code-of-conduct.md
205+
[node]: https://github.com/syntax-tree/hast#nodes

0 commit comments

Comments
 (0)