@@ -37,8 +37,8 @@ The latest released version is [`2.3.0`][latest].
37
37
38
38
## Introduction
39
39
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 ] .
42
42
Development of hast started in April 2016 for [ rehype] [ ] .
43
43
This specification is written in a [ Web IDL] [ webidl ] -like grammar.
44
44
@@ -50,8 +50,8 @@ hast extends [unist][], a format for syntax trees, to benefit from its
50
50
hast relates to [ JavaScript] [ ] in that it has an [ ecosystem of
51
51
utilities] [ list-of-utilities ] for working with compliant syntax trees in
52
52
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.
55
55
56
56
hast relates to the [ unified] [ ] and [ rehype] [ ] projects in that hast syntax
57
57
trees are used throughout their ecosystems.
@@ -60,12 +60,12 @@ trees are used throughout their ecosystems.
60
60
61
61
The reason for introducing a new “virtual” DOM is primarily:
62
62
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
65
65
* 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
69
69
70
70
## Nodes
71
71
@@ -119,11 +119,11 @@ interface Element <: Parent {
119
119
}
120
120
```
121
121
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 ] ) .
124
124
125
125
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 ] ) .
127
127
128
128
The ` properties ` field represents information associated with the element.
129
129
The value of the ` properties ` field implements the
@@ -136,22 +136,23 @@ If the `tagName` field is `'template'`, the element must be a
136
136
[ * leaf* ] [ term-leaf ] .
137
137
138
138
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 ] ).
140
141
141
142
For example, the following HTML:
142
143
143
144
``` html
144
- <a href =" http ://alpha.com" class =" bravo" download ></a >
145
+ <a href =" https ://alpha.com" class =" bravo" download ></a >
145
146
```
146
147
147
148
Yields:
148
149
149
- ``` javascript
150
+ ``` js
150
151
{
151
152
type: ' element' ,
152
153
tagName: ' a' ,
153
154
properties: {
154
- href: ' http ://alpha.com' ,
155
+ href: ' https ://alpha.com' ,
155
156
className: [' bravo' ],
156
157
download: true
157
158
},
@@ -188,8 +189,8 @@ notable differences.
188
189
The following rules are used to transform HTML attribute names to property
189
190
names.
190
191
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.
193
194
194
195
1 . Any name referencing a combinations of multiple words (such as “stroke
195
196
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
262
263
> included.
263
264
> In [ JavaScript] [ ] , both ` null ` and ` undefined ` must be similarly ignored.
264
265
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.
267
268
Where the DOM treats ` <div hidden="no"></div> ` as having a value of ` true ` and
268
269
` <img width="yes"> ` as having a value of ` 0 ` , these should be reflected as
269
270
` 'no' ` and ` 'yes' ` , respectively, in hast.
@@ -289,8 +290,8 @@ interface Doctype <: Node {
289
290
}
290
291
```
291
292
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 ] ) .
294
295
295
296
A ` name ` field must be present.
296
297
@@ -310,7 +311,7 @@ For example, the following HTML:
310
311
311
312
Yields:
312
313
313
- ``` javascript
314
+ ``` js
314
315
{
315
316
type: ' doctype' ,
316
317
name: ' html' ,
@@ -327,8 +328,8 @@ interface Comment <: Literal {
327
328
}
328
329
```
329
330
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 ] ) .
332
333
333
334
For example, the following HTML:
334
335
@@ -338,11 +339,8 @@ For example, the following HTML:
338
339
339
340
Yields:
340
341
341
- ``` javascript
342
- {
343
- type: ' comment' ,
344
- value: ' Charlie'
345
- }
342
+ ``` js
343
+ {type: ' comment' , value: ' Charlie' }
346
344
```
347
345
348
346
### ` Text `
@@ -353,7 +351,8 @@ interface Text <: Literal {
353
351
}
354
352
```
355
353
356
- ** Text** ([ ** Literal** ] [ dfn-literal ] ) represents an [ HTML Text] [ concept-text ] .
354
+ ** Text** ([ ** Literal** ] [ dfn-literal ] ) represents a [ Text] [ concept-text ]
355
+ ([ \[ DOM\] ] [ dom ] ).
357
356
358
357
For example, the following HTML:
359
358
@@ -363,7 +362,7 @@ For example, the following HTML:
363
362
364
363
Yields:
365
364
366
- ``` javascript
365
+ ``` js
367
366
{
368
367
type: ' element' ,
369
368
tagName: ' span' ,
@@ -515,13 +514,19 @@ The rest is sorted alphabetically based on content after `hast-util-`
515
514
* ** unist** :
516
515
[ Universal Syntax Tree] [ unist ] .
517
516
T. Wormer; et al.
518
- * ** JavaScript**
517
+ * ** JavaScript** :
519
518
[ ECMAScript Language Specification] [ javascript ] .
520
519
Ecma International.
521
520
* ** HTML** :
522
521
[ HTML Standard] [ html ] ,
523
522
A. van Kesteren; et al.
524
523
WHATWG.
524
+ * ** DOM** :
525
+ [ DOM Standard] [ dom ] ,
526
+ A. van Kesteren,
527
+ A. Gregor,
528
+ Ms2ger.
529
+ WHATWG.
525
530
* ** SVG** :
526
531
[ Scalable Vector Graphics (SVG)] [ svg ] ,
527
532
N. Andronikos,
@@ -636,6 +641,8 @@ for contributing to hast and related projects!
636
641
637
642
[ javascript ] : https://www.ecma-international.org/ecma-262/9.0/index.html
638
643
644
+ [ dom ] : https://dom.spec.whatwg.org/
645
+
639
646
[ html ] : https://html.spec.whatwg.org/multipage/
640
647
641
648
[ svg ] : https://svgwg.org/svg2-draft/
@@ -670,7 +677,7 @@ for contributing to hast and related projects!
670
677
671
678
[ concept-text ] : https://dom.spec.whatwg.org/#interface-text
672
679
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
674
681
675
682
[ concept-aria-reflection ] : https://w3c.github.io/aria/#idl_attr_disambiguation
676
683
0 commit comments