File tree 1 file changed +17
-2
lines changed
1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 2
2
* @typedef {import('xast').Root } Root
3
3
* @typedef {import('xast').Element } Element
4
4
* @typedef {import('xast').RootChildMap } RootChildMap
5
+ */
6
+
7
+ /**
5
8
* @typedef {RootChildMap[keyof RootChildMap] } Child
6
- * @typedef {Root| Child } Node
7
- * @typedef {Root| Element } Parent
9
+ * @typedef {Root | Child } Node
10
+ * @typedef {Root | Element } Parent
8
11
*/
9
12
10
13
/**
14
+ * Get the plain-text value of a node.
15
+ *
11
16
* @param {Node } node
17
+ * Node to serialize.
12
18
* @returns {string }
19
+ * Serialized node.
13
20
*/
14
21
export function toString ( node ) {
15
22
// A root or an element
@@ -18,8 +25,12 @@ export function toString(node) {
18
25
}
19
26
20
27
/**
28
+ * Serialize a child.
29
+ *
21
30
* @param {Node } node
31
+ * Child to serialize.
22
32
* @returns {string }
33
+ * Serialized node.
23
34
*/
24
35
function one ( node ) {
25
36
if ( node . type === 'text' ) return node . value
@@ -28,8 +39,12 @@ function one(node) {
28
39
}
29
40
30
41
/**
42
+ * Serialize a parent.
43
+ *
31
44
* @param {Parent } node
45
+ * Parent to serialize.
32
46
* @returns {string }
47
+ * Serialized node.
33
48
*/
34
49
function all ( node ) {
35
50
const children = node . children
You can’t perform that action at this time.
0 commit comments