@@ -7,39 +7,40 @@ var xtend = require('xtend');
7
7
var one = require ( './one' ) ;
8
8
var handlers = require ( './handlers' ) ;
9
9
10
- h . augment = augment ;
11
-
12
10
function toMDAST ( tree , options ) {
13
- options = options || { } ;
14
- h . handlers = xtend ( handlers , options . handlers || { } ) ;
11
+ var settings = options || { } ;
12
+
13
+ h . handlers = xtend ( handlers , settings . handlers || { } ) ;
14
+ h . augment = augment ;
15
+
15
16
return one ( h , minify ( tree ) , null ) ;
16
- }
17
17
18
- function h ( node , type , props , children ) {
19
- var result ;
18
+ function h ( node , type , props , children ) {
19
+ var result ;
20
20
21
- if ( ! children && ( ( typeof props === 'object' && 'length' in props ) || typeof props === 'string' ) ) {
22
- children = props ;
23
- props = { } ;
24
- }
21
+ if ( ! children && ( ( typeof props === 'object' && 'length' in props ) || typeof props === 'string' ) ) {
22
+ children = props ;
23
+ props = { } ;
24
+ }
25
+
26
+ result = xtend ( { type : type } , props ) ;
25
27
26
- result = xtend ( { type : type } , props ) ;
28
+ if ( typeof children === 'string' ) {
29
+ result . value = children ;
30
+ } else if ( children ) {
31
+ result . children = children ;
32
+ }
27
33
28
- if ( typeof children === 'string' ) {
29
- result . value = children ;
30
- } else if ( children ) {
31
- result . children = children ;
34
+ return augment ( node , result ) ;
32
35
}
33
36
34
- return augment ( node , result ) ;
35
- }
37
+ /* `right` is the finalized MDAST node,
38
+ * created from `left`, a HAST node */
39
+ function augment ( left , right ) {
40
+ if ( left . position ) {
41
+ right . position = left . position ;
42
+ }
36
43
37
- /* `right` is the finalized MDAST node,
38
- * created from `left`, a HAST node */
39
- function augment ( left , right ) {
40
- if ( left . position ) {
41
- right . position = left . position ;
44
+ return right ;
42
45
}
43
-
44
- return right ;
45
46
}
0 commit comments