@@ -6,10 +6,10 @@ var zwitch = require('zwitch')
66var mapz = require ( 'mapz' )
77var unist = require ( 'unist-util-assert' )
88
9- /* Construct. */
9+ // Construct.
1010var mdast = zwitch ( 'type' )
1111
12- /* Expose. */
12+ // Expose.
1313exports = unist . wrap ( mdast )
1414module . exports = exports
1515
@@ -19,11 +19,11 @@ exports.void = unist.void
1919exports . wrap = unist . wrap
2020exports . all = mapz ( exports , { key : 'children' , indices : false } )
2121
22- /* Core interface. */
22+ // Core interface.
2323mdast . unknown = unknown
2424mdast . invalid = unknown
2525
26- /* Per-type handling. */
26+ // Per-type handling.
2727mdast . handlers = {
2828 root : unist . wrap ( root ) ,
2929 paragraph : exports . parent ,
@@ -39,6 +39,7 @@ mdast.handlers = {
3939 text : exports . text ,
4040 inlineCode : exports . text ,
4141 yaml : exports . text ,
42+ toml : exports . text ,
4243 code : unist . wrap ( code ) ,
4344 thematicBreak : exports . void ,
4445 break : exports . void ,
@@ -72,11 +73,11 @@ function root(node, ancestor) {
7273function list ( node ) {
7374 parent ( node )
7475
75- if ( node . loose != null ) {
76+ if ( node . spread != null ) {
7677 assert . strictEqual (
77- typeof node . loose ,
78+ typeof node . spread ,
7879 'boolean' ,
79- '`loose ` must be `boolean`'
80+ '`spread ` must be `boolean`'
8081 )
8182 }
8283
@@ -103,11 +104,11 @@ function list(node) {
103104function listItem ( node ) {
104105 parent ( node )
105106
106- if ( node . loose != null ) {
107+ if ( node . spread != null ) {
107108 assert . strictEqual (
108- typeof node . loose ,
109+ typeof node . spread ,
109110 'boolean' ,
110- '`loose ` must be `boolean`'
111+ '`spread ` must be `boolean`'
111112 )
112113 }
113114
@@ -133,6 +134,11 @@ function code(node) {
133134 if ( node . lang != null ) {
134135 assert . strictEqual ( typeof node . lang , 'string' , '`lang` must be `string`' )
135136 }
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+ }
136142}
137143
138144function footnoteDefinition ( node ) {
@@ -143,6 +149,10 @@ function footnoteDefinition(node) {
143149 'string' ,
144150 '`footnoteDefinition` must have `identifier`'
145151 )
152+
153+ if ( node . label != null ) {
154+ assert . strictEqual ( typeof node . label , 'string' , '`label` must be `string`' )
155+ }
146156}
147157
148158function definition ( node ) {
@@ -154,10 +164,12 @@ function definition(node) {
154164 '`identifier` must be `string`'
155165 )
156166
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`' )
159169 }
160170
171+ assert . strictEqual ( typeof node . url , 'string' , '`url` must be `string`' )
172+
161173 if ( node . title != null ) {
162174 assert . strictEqual ( typeof node . title , 'string' , '`title` must be `string`' )
163175 }
@@ -166,9 +178,7 @@ function definition(node) {
166178function link ( node ) {
167179 parent ( node )
168180
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`' )
172182
173183 if ( node . title != null ) {
174184 assert . strictEqual ( typeof node . title , 'string' , '`title` must be `string`' )
@@ -178,17 +188,15 @@ function link(node) {
178188function image ( node ) {
179189 unist . void ( node )
180190
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`' )
183195 }
184196
185197 if ( node . alt != null ) {
186198 assert . strictEqual ( typeof node . alt , 'string' , '`alt` must be `string`' )
187199 }
188-
189- if ( node . title != null ) {
190- assert . strictEqual ( typeof node . title , 'string' , '`title` must be `string`' )
191- }
192200}
193201
194202function linkReference ( node ) {
@@ -200,6 +208,10 @@ function linkReference(node) {
200208 '`identifier` must be `string`'
201209 )
202210
211+ if ( node . label != null ) {
212+ assert . strictEqual ( typeof node . label , 'string' , '`label` must be `string`' )
213+ }
214+
203215 if ( node . referenceType != null ) {
204216 assert . notStrictEqual (
205217 [ 'shortcut' , 'collapsed' , 'full' ] . indexOf ( node . referenceType ) ,
@@ -218,6 +230,10 @@ function imageReference(node) {
218230 '`identifier` must be `string`'
219231 )
220232
233+ if ( node . label != null ) {
234+ assert . strictEqual ( typeof node . label , 'string' , '`label` must be `string`' )
235+ }
236+
221237 if ( node . alt != null ) {
222238 assert . strictEqual ( typeof node . alt , 'string' , '`alt` must be `string`' )
223239 }
@@ -239,6 +255,10 @@ function footnoteReference(node) {
239255 'string' ,
240256 '`identifier` must be `string`'
241257 )
258+
259+ if ( node . label != null ) {
260+ assert . strictEqual ( typeof node . label , 'string' , '`label` must be `string`' )
261+ }
242262}
243263
244264function table ( node ) {
0 commit comments