1+ import assert from 'node:assert/strict'
12import fs from 'node:fs'
23import path from 'node:path'
34import test from 'tape'
@@ -248,7 +249,7 @@ test('mdast -> markdown', (t) => {
248249
249250 t . deepEqual (
250251 toMarkdown (
251- { type : 'definition' , label : 'http://a' } ,
252+ { type : 'definition' , label : 'http://a' , identifier : '' , url : '' } ,
252253 { extensions : [ gfmAutolinkLiteralToMarkdown ] }
253254 ) ,
254255 '[http://a]: <>\n' ,
@@ -263,6 +264,8 @@ test('mdast -> markdown', (t) => {
263264 {
264265 type : 'linkReference' ,
265266 label : 'http://a' ,
267+ identifier : '' ,
268+ referenceType : 'collapsed' ,
266269 children : [ { type : 'text' , value : 'http://a' } ]
267270 }
268271 ]
@@ -281,6 +284,8 @@ test('mdast -> markdown', (t) => {
281284 {
282285 type : 'linkReference' ,
283286 label : 'a' ,
287+ identifier : '' ,
288+ referenceType : 'full' ,
284289 children : [ { type : 'text' , value : 'http://a' } ]
285290 }
286291 ]
@@ -299,6 +304,8 @@ test('mdast -> markdown', (t) => {
299304 {
300305 type : 'linkReference' ,
301306 label : 'http://a' ,
307+ identifier : '' ,
308+ referenceType : 'full' ,
302309 children : [ { type : 'text' , value : 'a' } ]
303310 }
304311 ]
@@ -331,7 +338,15 @@ test('mdast -> markdown', (t) => {
331338 toMarkdown (
332339 {
333340 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+ ]
335350 } ,
336351 { extensions : [ gfmAutolinkLiteralToMarkdown ] }
337352 ) ,
@@ -343,7 +358,15 @@ test('mdast -> markdown', (t) => {
343358 toMarkdown (
344359 {
345360 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+ ]
347370 } ,
348371 { extensions : [ gfmAutolinkLiteralToMarkdown ] }
349372 ) ,
@@ -369,16 +392,18 @@ test('mdast -> markdown', (t) => {
369392 while ( ++ index < files . length ) {
370393 const d = files [ index ]
371394 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 }
381401 )
402+ assert ( hast && hast . type === 'root' , 'expected root' )
403+ let actual = toHtml ( hast , {
404+ allowDangerousHtml : true ,
405+ entities : { useNamedReferences : true }
406+ } )
382407 const expected = String ( fs . readFileSync ( path . join ( 'test' , stem + '.html' ) ) )
383408
384409 if ( actual . charCodeAt ( actual . length - 1 ) !== 10 ) {
0 commit comments