@@ -6,10 +6,10 @@ var zwitch = require('zwitch')
6
6
var mapz = require ( 'mapz' )
7
7
var unist = require ( 'unist-util-assert' )
8
8
9
- /* Construct. */
9
+ // Construct.
10
10
var mdast = zwitch ( 'type' )
11
11
12
- /* Expose. */
12
+ // Expose.
13
13
exports = unist . wrap ( mdast )
14
14
module . exports = exports
15
15
@@ -19,11 +19,11 @@ exports.void = unist.void
19
19
exports . wrap = unist . wrap
20
20
exports . all = mapz ( exports , { key : 'children' , indices : false } )
21
21
22
- /* Core interface. */
22
+ // Core interface.
23
23
mdast . unknown = unknown
24
24
mdast . invalid = unknown
25
25
26
- /* Per-type handling. */
26
+ // Per-type handling.
27
27
mdast . handlers = {
28
28
root : unist . wrap ( root ) ,
29
29
paragraph : exports . parent ,
@@ -39,6 +39,7 @@ mdast.handlers = {
39
39
text : exports . text ,
40
40
inlineCode : exports . text ,
41
41
yaml : exports . text ,
42
+ toml : exports . text ,
42
43
code : unist . wrap ( code ) ,
43
44
thematicBreak : exports . void ,
44
45
break : exports . void ,
@@ -72,11 +73,11 @@ function root(node, ancestor) {
72
73
function list ( node ) {
73
74
parent ( node )
74
75
75
- if ( node . loose != null ) {
76
+ if ( node . spread != null ) {
76
77
assert . strictEqual (
77
- typeof node . loose ,
78
+ typeof node . spread ,
78
79
'boolean' ,
79
- '`loose ` must be `boolean`'
80
+ '`spread ` must be `boolean`'
80
81
)
81
82
}
82
83
@@ -103,11 +104,11 @@ function list(node) {
103
104
function listItem ( node ) {
104
105
parent ( node )
105
106
106
- if ( node . loose != null ) {
107
+ if ( node . spread != null ) {
107
108
assert . strictEqual (
108
- typeof node . loose ,
109
+ typeof node . spread ,
109
110
'boolean' ,
110
- '`loose ` must be `boolean`'
111
+ '`spread ` must be `boolean`'
111
112
)
112
113
}
113
114
@@ -133,6 +134,11 @@ function code(node) {
133
134
if ( node . lang != null ) {
134
135
assert . strictEqual ( typeof node . lang , 'string' , '`lang` must be `string`' )
135
136
}
137
+
138
+ if ( node . meta != null ) {
139
+ assert . ok ( node . lang != null , 'code with `meta` must also have `lang`' )
140
+ assert . strictEqual ( typeof node . meta , 'string' , '`meta` must be `string`' )
141
+ }
136
142
}
137
143
138
144
function footnoteDefinition ( node ) {
@@ -143,6 +149,10 @@ function footnoteDefinition(node) {
143
149
'string' ,
144
150
'`footnoteDefinition` must have `identifier`'
145
151
)
152
+
153
+ if ( node . label != null ) {
154
+ assert . strictEqual ( typeof node . label , 'string' , '`label` must be `string`' )
155
+ }
146
156
}
147
157
148
158
function definition ( node ) {
@@ -154,10 +164,12 @@ function definition(node) {
154
164
'`identifier` must be `string`'
155
165
)
156
166
157
- if ( node . url != null ) {
158
- assert . strictEqual ( typeof node . url , 'string' , '`url ` must be `string`' )
167
+ if ( node . label != null ) {
168
+ assert . strictEqual ( typeof node . label , 'string' , '`label ` must be `string`' )
159
169
}
160
170
171
+ assert . strictEqual ( typeof node . url , 'string' , '`url` must be `string`' )
172
+
161
173
if ( node . title != null ) {
162
174
assert . strictEqual ( typeof node . title , 'string' , '`title` must be `string`' )
163
175
}
@@ -166,9 +178,7 @@ function definition(node) {
166
178
function link ( node ) {
167
179
parent ( node )
168
180
169
- if ( node . url != null ) {
170
- assert . strictEqual ( typeof node . url , 'string' , '`url` must be `string`' )
171
- }
181
+ assert . strictEqual ( typeof node . url , 'string' , '`url` must be `string`' )
172
182
173
183
if ( node . title != null ) {
174
184
assert . strictEqual ( typeof node . title , 'string' , '`title` must be `string`' )
@@ -178,17 +188,15 @@ function link(node) {
178
188
function image ( node ) {
179
189
unist . void ( node )
180
190
181
- if ( node . url != null ) {
182
- assert . strictEqual ( typeof node . url , 'string' , '`url` must be `string`' )
191
+ assert . strictEqual ( typeof node . url , 'string' , '`url` must be `string`' )
192
+
193
+ if ( node . title != null ) {
194
+ assert . strictEqual ( typeof node . title , 'string' , '`title` must be `string`' )
183
195
}
184
196
185
197
if ( node . alt != null ) {
186
198
assert . strictEqual ( typeof node . alt , 'string' , '`alt` must be `string`' )
187
199
}
188
-
189
- if ( node . title != null ) {
190
- assert . strictEqual ( typeof node . title , 'string' , '`title` must be `string`' )
191
- }
192
200
}
193
201
194
202
function linkReference ( node ) {
@@ -200,6 +208,10 @@ function linkReference(node) {
200
208
'`identifier` must be `string`'
201
209
)
202
210
211
+ if ( node . label != null ) {
212
+ assert . strictEqual ( typeof node . label , 'string' , '`label` must be `string`' )
213
+ }
214
+
203
215
if ( node . referenceType != null ) {
204
216
assert . notStrictEqual (
205
217
[ 'shortcut' , 'collapsed' , 'full' ] . indexOf ( node . referenceType ) ,
@@ -218,6 +230,10 @@ function imageReference(node) {
218
230
'`identifier` must be `string`'
219
231
)
220
232
233
+ if ( node . label != null ) {
234
+ assert . strictEqual ( typeof node . label , 'string' , '`label` must be `string`' )
235
+ }
236
+
221
237
if ( node . alt != null ) {
222
238
assert . strictEqual ( typeof node . alt , 'string' , '`alt` must be `string`' )
223
239
}
@@ -239,6 +255,10 @@ function footnoteReference(node) {
239
255
'string' ,
240
256
'`identifier` must be `string`'
241
257
)
258
+
259
+ if ( node . label != null ) {
260
+ assert . strictEqual ( typeof node . label , 'string' , '`label` must be `string`' )
261
+ }
242
262
}
243
263
244
264
function table ( node ) {
0 commit comments