1
+ import assert from 'node:assert/strict'
1
2
import fs from 'node:fs'
2
3
import path from 'node:path'
3
4
import test from 'tape'
@@ -248,7 +249,7 @@ test('mdast -> markdown', (t) => {
248
249
249
250
t . deepEqual (
250
251
toMarkdown (
251
- { type : 'definition' , label : 'http://a' } ,
252
+ { type : 'definition' , label : 'http://a' , identifier : '' , url : '' } ,
252
253
{ extensions : [ gfmAutolinkLiteralToMarkdown ] }
253
254
) ,
254
255
'[http://a]: <>\n' ,
@@ -263,6 +264,8 @@ test('mdast -> markdown', (t) => {
263
264
{
264
265
type : 'linkReference' ,
265
266
label : 'http://a' ,
267
+ identifier : '' ,
268
+ referenceType : 'collapsed' ,
266
269
children : [ { type : 'text' , value : 'http://a' } ]
267
270
}
268
271
]
@@ -281,6 +284,8 @@ test('mdast -> markdown', (t) => {
281
284
{
282
285
type : 'linkReference' ,
283
286
label : 'a' ,
287
+ identifier : '' ,
288
+ referenceType : 'full' ,
284
289
children : [ { type : 'text' , value : 'http://a' } ]
285
290
}
286
291
]
@@ -299,6 +304,8 @@ test('mdast -> markdown', (t) => {
299
304
{
300
305
type : 'linkReference' ,
301
306
label : 'http://a' ,
307
+ identifier : '' ,
308
+ referenceType : 'full' ,
302
309
children : [ { type : 'text' , value : 'a' } ]
303
310
}
304
311
]
@@ -331,7 +338,15 @@ test('mdast -> markdown', (t) => {
331
338
toMarkdown (
332
339
{
333
340
type : 'paragraph' ,
334
- children : [ { type : 'imageReference' , label : 'http://a' , alt : 'a' } ]
341
+ children : [
342
+ {
343
+ type : 'imageReference' ,
344
+ label : 'http://a' ,
345
+ identifier : '' ,
346
+ referenceType : 'full' ,
347
+ alt : 'a'
348
+ }
349
+ ]
335
350
} ,
336
351
{ extensions : [ gfmAutolinkLiteralToMarkdown ] }
337
352
) ,
@@ -343,7 +358,15 @@ test('mdast -> markdown', (t) => {
343
358
toMarkdown (
344
359
{
345
360
type : 'paragraph' ,
346
- children : [ { type : 'imageReference' , label : 'a' , alt : 'http://a' } ]
361
+ children : [
362
+ {
363
+ type : 'imageReference' ,
364
+ label : 'a' ,
365
+ identifier : '' ,
366
+ referenceType : 'full' ,
367
+ alt : 'http://a'
368
+ }
369
+ ]
347
370
} ,
348
371
{ extensions : [ gfmAutolinkLiteralToMarkdown ] }
349
372
) ,
@@ -369,16 +392,18 @@ test('mdast -> markdown', (t) => {
369
392
while ( ++ index < files . length ) {
370
393
const d = files [ index ]
371
394
const stem = path . basename ( d , '.md' )
372
- let actual = toHtml (
373
- toHast (
374
- fromMarkdown ( fs . readFileSync ( path . join ( 'test' , d ) ) , {
375
- extensions : [ gfmAutolinkLiteral ] ,
376
- mdastExtensions : [ gfmAutolinkLiteralFromMarkdown ]
377
- } ) ,
378
- { allowDangerousHtml : true }
379
- ) ,
380
- { allowDangerousHtml : true , entities : { useNamedReferences : true } }
395
+ const hast = toHast (
396
+ fromMarkdown ( fs . readFileSync ( path . join ( 'test' , d ) ) , {
397
+ extensions : [ gfmAutolinkLiteral ] ,
398
+ mdastExtensions : [ gfmAutolinkLiteralFromMarkdown ]
399
+ } ) ,
400
+ { allowDangerousHtml : true }
381
401
)
402
+ assert ( hast && hast . type === 'root' , 'expected root' )
403
+ let actual = toHtml ( hast , {
404
+ allowDangerousHtml : true ,
405
+ entities : { useNamedReferences : true }
406
+ } )
382
407
const expected = String ( fs . readFileSync ( path . join ( 'test' , stem + '.html' ) ) )
383
408
384
409
if ( actual . charCodeAt ( actual . length - 1 ) !== 10 ) {
0 commit comments