Skip to content

Commit f3b996c

Browse files
committed
Refactor prose
1 parent ee60d70 commit f3b996c

File tree

1 file changed

+41
-34
lines changed

1 file changed

+41
-34
lines changed

readme.md

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ The latest released version is [`2.3.0`][latest].
3737

3838
## Introduction
3939

40-
This document defines a format for representing hypertext as an [abstract
41-
syntax tree][syntax-tree].
40+
This document defines a format for representing hypertext as an [abstract syntax
41+
tree][syntax-tree].
4242
Development of hast started in April 2016 for [rehype][].
4343
This specification is written in a [Web IDL][webidl]-like grammar.
4444

@@ -50,8 +50,8 @@ hast extends [unist][], a format for syntax trees, to benefit from its
5050
hast relates to [JavaScript][] in that it has an [ecosystem of
5151
utilities][list-of-utilities] for working with compliant syntax trees in
5252
JavaScript.
53-
However, hast is not limited to JavaScript and can be used in other
54-
programming languages.
53+
However, hast is not limited to JavaScript and can be used in other programming
54+
languages.
5555

5656
hast relates to the [unified][] and [rehype][] projects in that hast syntax
5757
trees are used throughout their ecosystems.
@@ -60,12 +60,12 @@ trees are used throughout their ecosystems.
6060

6161
The reason for introducing a new “virtual” DOM is primarily:
6262

63-
* The DOM is very heavy to implement outside of the browser,
64-
a lean and stripped down virtual DOM can be used everywhere
63+
* The [DOM][] is very heavy to implement outside of the browser, a lean and
64+
stripped down virtual DOM can be used everywhere
6565
* Most virtual DOMs do not focus on ease of use in transformations
66-
* Other virtual DOMs cannot represent the syntax of HTML in its
67-
entirety (think comments and document types)
68-
* Neither HTML nor virtual DOMs focus on positional information
66+
* Other virtual DOMs cannot represent the syntax of HTML in its entirety
67+
(think comments and document types)
68+
* Neither the DOM nor virtual DOMs focus on positional information
6969

7070
## Nodes
7171

@@ -119,11 +119,11 @@ interface Element <: Parent {
119119
}
120120
```
121121

122-
**Element** ([**Parent**][dfn-parent]) represents an [HTML
123-
Element][concept-element].
122+
**Element** ([**Parent**][dfn-parent]) represents an [Element][concept-element]
123+
([\[DOM\]][dom]).
124124

125125
A `tagName` field must be present.
126-
It represents the element’s [local name][concept-local-name].
126+
It represents the element’s [local name][concept-local-name] ([\[DOM\]][dom]).
127127

128128
The `properties` field represents information associated with the element.
129129
The value of the `properties` field implements the
@@ -136,22 +136,23 @@ If the `tagName` field is `'template'`, the element must be a
136136
[*leaf*][term-leaf].
137137

138138
If the `tagName` field is `'noscript'`, its [*children*][term-child] should
139-
be represented as if [*scripting is disabled*][concept-scripting].
139+
be represented as if [*scripting is disabled*][concept-scripting]
140+
([\[HTML\]][html]).
140141

141142
For example, the following HTML:
142143

143144
```html
144-
<a href="http://alpha.com" class="bravo" download></a>
145+
<a href="https://alpha.com" class="bravo" download></a>
145146
```
146147

147148
Yields:
148149

149-
```javascript
150+
```js
150151
{
151152
type: 'element',
152153
tagName: 'a',
153154
properties: {
154-
href: 'http://alpha.com',
155+
href: 'https://alpha.com',
155156
className: ['bravo'],
156157
download: true
157158
},
@@ -188,8 +189,8 @@ notable differences.
188189
The following rules are used to transform HTML attribute names to property
189190
names.
190191
These rules are based on [how ARIA is reflected in the
191-
DOM][concept-aria-reflection], and differs from how some (older) HTML attributes
192-
are reflected in the DOM.
192+
DOM][concept-aria-reflection] ([\[ARIA\]][aria]), and differs from how some
193+
(older) HTML attributes are reflected in the DOM.
193194

194195
1. Any name referencing a combinations of multiple words (such as “stroke
195196
miter limit”) becomes a camel-cased property name capitalising each word
@@ -262,8 +263,8 @@ reflected as a `hidden` property name set to the property value `true`, and
262263
> included.
263264
> In [JavaScript][], both `null` and `undefined` must be similarly ignored.
264265
265-
The DOM has strict rules on how it coerces HTML to expected values, whereas
266-
hast is more lenient in how it reflects the source.
266+
The DOM has strict rules on how it coerces HTML to expected values, whereas hast
267+
is more lenient in how it reflects the source.
267268
Where the DOM treats `<div hidden="no"></div>` as having a value of `true` and
268269
`<img width="yes">` as having a value of `0`, these should be reflected as
269270
`'no'` and `'yes'`, respectively, in hast.
@@ -289,8 +290,8 @@ interface Doctype <: Node {
289290
}
290291
```
291292

292-
**Doctype** ([**Node**][dfn-unist-node]) represents an [HTML
293-
DocumentType][concept-documenttype].
293+
**Doctype** ([**Node**][dfn-unist-node]) represents a
294+
[DocumentType][concept-documenttype] ([\[DOM\]][dom]).
294295

295296
A `name` field must be present.
296297

@@ -310,7 +311,7 @@ For example, the following HTML:
310311

311312
Yields:
312313

313-
```javascript
314+
```js
314315
{
315316
type: 'doctype',
316317
name: 'html',
@@ -327,8 +328,8 @@ interface Comment <: Literal {
327328
}
328329
```
329330

330-
**Comment** ([**Literal**][dfn-literal]) represents an [HTML
331-
Comment][concept-comment].
331+
**Comment** ([**Literal**][dfn-literal]) represents a [Comment][concept-comment]
332+
([\[DOM\]][dom]).
332333

333334
For example, the following HTML:
334335

@@ -338,11 +339,8 @@ For example, the following HTML:
338339

339340
Yields:
340341

341-
```javascript
342-
{
343-
type: 'comment',
344-
value: 'Charlie'
345-
}
342+
```js
343+
{type: 'comment', value: 'Charlie'}
346344
```
347345

348346
### `Text`
@@ -353,7 +351,8 @@ interface Text <: Literal {
353351
}
354352
```
355353

356-
**Text** ([**Literal**][dfn-literal]) represents an [HTML Text][concept-text].
354+
**Text** ([**Literal**][dfn-literal]) represents a [Text][concept-text]
355+
([\[DOM\]][dom]).
357356

358357
For example, the following HTML:
359358

@@ -363,7 +362,7 @@ For example, the following HTML:
363362

364363
Yields:
365364

366-
```javascript
365+
```js
367366
{
368367
type: 'element',
369368
tagName: 'span',
@@ -515,13 +514,19 @@ The rest is sorted alphabetically based on content after `hast-util-`
515514
* **unist**:
516515
[Universal Syntax Tree][unist].
517516
T. Wormer; et al.
518-
* **JavaScript**
517+
* **JavaScript**:
519518
[ECMAScript Language Specification][javascript].
520519
Ecma International.
521520
* **HTML**:
522521
[HTML Standard][html],
523522
A. van Kesteren; et al.
524523
WHATWG.
524+
* **DOM**:
525+
[DOM Standard][dom],
526+
A. van Kesteren,
527+
A. Gregor,
528+
Ms2ger.
529+
WHATWG.
525530
* **SVG**:
526531
[Scalable Vector Graphics (SVG)][svg],
527532
N. Andronikos,
@@ -636,6 +641,8 @@ for contributing to hast and related projects!
636641

637642
[javascript]: https://www.ecma-international.org/ecma-262/9.0/index.html
638643

644+
[dom]: https://dom.spec.whatwg.org/
645+
639646
[html]: https://html.spec.whatwg.org/multipage/
640647

641648
[svg]: https://svgwg.org/svg2-draft/
@@ -670,7 +677,7 @@ for contributing to hast and related projects!
670677

671678
[concept-text]: https://dom.spec.whatwg.org/#interface-text
672679

673-
[concept-scripting]: https://html.spec.whatwg.org/#enabling-and-disabling-scripting
680+
[concept-scripting]: https://html.spec.whatwg.org/multipage/webappapis.html#enabling-and-disabling-scripting
674681

675682
[concept-aria-reflection]: https://w3c.github.io/aria/#idl_attr_disambiguation
676683

0 commit comments

Comments
 (0)