6
6
* @typedef {import('mdast').Content } MdastContent
7
7
* @typedef {import('mdast').BlockContent } MdastBlockContent
8
8
* @typedef {import('mdast').DefinitionContent } MdastDefinitionContent
9
- * @typedef {import('mdast').PhrasingContent } MdastPhrasingContent
10
9
* @typedef {import('./types.js').Options } Options
11
10
* @typedef {import('./types.js').Handle } Handle
12
11
* @typedef {import('./types.js').NodeHandle } NodeHandle
21
20
*
22
21
* @typedef State
23
22
* Info passed around about the current state.
24
- * @property {PatchPosition } patch
23
+ * @property {Patch } patch
25
24
* Copy a node’s positional info.
25
+ * @property {One } one
26
+ * Transform a hast node to mdast.
26
27
* @property {All } all
27
28
* Transform the children of a hast parent to mdast.
28
29
* @property {ToFlow } toFlow
29
- * Transform the children of a hast parent to mdast flow content .
30
+ * Transform a list of mdast nodes to flow.
30
31
* @property {<ChildType extends MdastNode, ParentType extends MdastParent & {'children': Array<ChildType>}>(nodes: Array<MdastContent>, build: (() => ParentType)) => Array<ParentType> } toSpecificContent
31
32
* Turn arbitrary content into a list of a particular node type.
32
33
*
35
36
* in this example, when non-items are found, they will be queued, and
36
37
* inserted into an adjacent item.
37
38
* When no actual items exist, one will be made with `build`.
38
- * @property {One } one
39
- * Transform a hast node to mdast.
40
39
* @property {Resolve } resolve
41
40
* Resolve a URL relative to a base.
42
41
* @property {Options } options
56
55
* @property {number } qNesting
57
56
* Non-negative finite integer representing how deep we’re in `<q>`s.
58
57
*
59
- * @callback PatchPosition
58
+ * @callback Patch
60
59
* Copy a node’s positional info.
61
- * @param {Node } origin
60
+ * @param {Node } from
62
61
* hast node to copy from.
63
- * @param {MdastNode } node
62
+ * @param {MdastNode } to
64
63
* mdast node to copy into.
65
64
* @returns {void }
66
65
* Nothing.
73
72
* mdast children.
74
73
*
75
74
* @callback ToFlow
76
- * Transform the children of a hast parent to mdast, as flow content .
75
+ * Transform a list of mdast nodes to flow.
77
76
* @param {Array<MdastContent> } nodes
78
77
* mdast nodes.
79
78
* @returns {Array<MdastFlowContent> }
@@ -233,7 +232,7 @@ function all(parent) {
233
232
}
234
233
235
234
/**
236
- * Transform the children of a hast parent to mdast .
235
+ * Transform a list of mdast nodes to flow .
237
236
*
238
237
* @this {State}
239
238
* Info passed around about the current state.
@@ -247,29 +246,7 @@ function toFlow(nodes) {
247
246
}
248
247
249
248
/**
250
- * @this {State}
251
- * Info passed around about the current state.
252
- * @param {string | null | undefined } url
253
- * Possible URL value.
254
- * @returns {string }
255
- * URL, resolved to a `base` element, if any.
256
- */
257
- function resolve ( url ) {
258
- const base = this . frozenBaseUrl
259
-
260
- if ( url === null || url === undefined ) {
261
- return ''
262
- }
263
-
264
- if ( base ) {
265
- return String ( new URL ( url , base ) )
266
- }
267
-
268
- return url
269
- }
270
-
271
- /**
272
- * Turn arbitrary content into a list of a particular node type.
249
+ * Turn arbitrary content into a particular node type.
273
250
*
274
251
* This is useful for example for lists, which must have list items as content.
275
252
* in this example, when non-items are found, they will be queued, and
@@ -335,3 +312,25 @@ function toSpecificContent(nodes, build) {
335
312
return node . type === reference . type
336
313
}
337
314
}
315
+
316
+ /**
317
+ * @this {State}
318
+ * Info passed around about the current state.
319
+ * @param {string | null | undefined } url
320
+ * Possible URL value.
321
+ * @returns {string }
322
+ * URL, resolved to a `base` element, if any.
323
+ */
324
+ function resolve ( url ) {
325
+ const base = this . frozenBaseUrl
326
+
327
+ if ( url === null || url === undefined ) {
328
+ return ''
329
+ }
330
+
331
+ if ( base ) {
332
+ return String ( new URL ( url , base ) )
333
+ }
334
+
335
+ return url
336
+ }
0 commit comments