2
2
* @typedef {import('./test-types.js') } DoNotTouchThisIncludesCustomNodesInTree
3
3
*/
4
4
5
- import test from 'tape'
5
+ import assert from 'node:assert/strict'
6
+ import test from 'node:test'
6
7
import { fromMarkdown } from 'mdast-util-from-markdown'
7
8
import { toMarkdown } from 'mdast-util-to-markdown'
8
9
import { removePosition } from 'unist-util-remove-position'
@@ -13,8 +14,8 @@ const custom = {type: 'custom', marker: {open: '<', close: '>'}}
13
14
const json = { type : 'json' , fence : { open : '{' , close : '}' } }
14
15
const yamlAnywhere = { type : 'yaml' , marker : '-' , anywhere : true }
15
16
16
- test ( 'markdown -> mdast ' , ( t ) => {
17
- t . deepEqual (
17
+ test ( 'frontmatterFromMarkdown ' , ( ) => {
18
+ assert . deepEqual (
18
19
removePosition (
19
20
fromMarkdown ( '---' , {
20
21
extensions : [ frontmatter ( ) ] ,
@@ -26,7 +27,7 @@ test('markdown -> mdast', (t) => {
26
27
'should not support a single yaml fence (thematic break)'
27
28
)
28
29
29
- t . deepEqual (
30
+ assert . deepEqual (
30
31
removePosition (
31
32
fromMarkdown ( '---\n---' , {
32
33
extensions : [ frontmatter ( ) ] ,
@@ -38,7 +39,7 @@ test('markdown -> mdast', (t) => {
38
39
'should parse empty yaml'
39
40
)
40
41
41
- t . deepEqual (
42
+ assert . deepEqual (
42
43
removePosition (
43
44
fromMarkdown ( ' ---\n---' , {
44
45
extensions : [ frontmatter ( ) ] ,
@@ -53,7 +54,7 @@ test('markdown -> mdast', (t) => {
53
54
'should not support a prefix (indent) before a yaml opening fence'
54
55
)
55
56
56
- t . deepEqual (
57
+ assert . deepEqual (
57
58
removePosition (
58
59
fromMarkdown ( '---\n ---' , {
59
60
extensions : [ frontmatter ( ) ] ,
@@ -68,7 +69,7 @@ test('markdown -> mdast', (t) => {
68
69
'should not support a prefix (indent) before a yaml closing fence'
69
70
)
70
71
71
- t . deepEqual (
72
+ assert . deepEqual (
72
73
removePosition (
73
74
fromMarkdown ( '--- \n---\t ' , {
74
75
extensions : [ frontmatter ( ) ] ,
@@ -80,7 +81,7 @@ test('markdown -> mdast', (t) => {
80
81
'should parse an arbitrary suffix after the opening and closing fence of yaml'
81
82
)
82
83
83
- t . deepEqual (
84
+ assert . deepEqual (
84
85
removePosition (
85
86
fromMarkdown ( '--- --\n---' , {
86
87
extensions : [ frontmatter ( ) ] ,
@@ -95,7 +96,7 @@ test('markdown -> mdast', (t) => {
95
96
'should not support other characters after the suffix on the opening fence of yaml'
96
97
)
97
98
98
- t . deepEqual (
99
+ assert . deepEqual (
99
100
removePosition (
100
101
fromMarkdown ( '---\n--- x' , {
101
102
extensions : [ frontmatter ( ) ] ,
@@ -113,7 +114,7 @@ test('markdown -> mdast', (t) => {
113
114
'should not support other characters after the suffix on the closing fence of yaml'
114
115
)
115
116
116
- t . deepEqual (
117
+ assert . deepEqual (
117
118
removePosition (
118
119
fromMarkdown ( '----\n---' , {
119
120
extensions : [ frontmatter ( ) ] ,
@@ -128,7 +129,7 @@ test('markdown -> mdast', (t) => {
128
129
'should not support an opening yaml fence of more than 3 characters'
129
130
)
130
131
131
- t . deepEqual (
132
+ assert . deepEqual (
132
133
removePosition (
133
134
fromMarkdown ( '---\n----' , {
134
135
extensions : [ frontmatter ( ) ] ,
@@ -143,7 +144,7 @@ test('markdown -> mdast', (t) => {
143
144
'should not support a closing yaml fence of more than 3 characters'
144
145
)
145
146
146
- t . deepEqual (
147
+ assert . deepEqual (
147
148
removePosition (
148
149
fromMarkdown ( '--\n---' , {
149
150
extensions : [ frontmatter ( ) ] ,
@@ -160,7 +161,7 @@ test('markdown -> mdast', (t) => {
160
161
'should not support an opening yaml fence of less than 3 characters'
161
162
)
162
163
163
- t . deepEqual (
164
+ assert . deepEqual (
164
165
removePosition (
165
166
fromMarkdown ( '---\n--' , {
166
167
extensions : [ frontmatter ( ) ] ,
@@ -178,7 +179,7 @@ test('markdown -> mdast', (t) => {
178
179
'should not support a closing yaml fence of less than 3 characters'
179
180
)
180
181
181
- t . deepEqual (
182
+ assert . deepEqual (
182
183
removePosition (
183
184
fromMarkdown ( '---\na\nb\n---' , {
184
185
extensions : [ frontmatter ( ) ] ,
@@ -190,7 +191,7 @@ test('markdown -> mdast', (t) => {
190
191
'should support content in yaml'
191
192
)
192
193
193
- t . deepEqual (
194
+ assert . deepEqual (
194
195
removePosition (
195
196
fromMarkdown ( '---\na\n\nb\n---' , {
196
197
extensions : [ frontmatter ( ) ] ,
@@ -202,7 +203,7 @@ test('markdown -> mdast', (t) => {
202
203
'should support blank lines in yaml'
203
204
)
204
205
205
- t . deepEqual (
206
+ assert . deepEqual (
206
207
removePosition (
207
208
fromMarkdown ( '+++\na\n\nb\n+++' , {
208
209
extensions : [ frontmatter ( 'toml' ) ] ,
@@ -214,7 +215,7 @@ test('markdown -> mdast', (t) => {
214
215
'should support toml'
215
216
)
216
217
217
- t . deepEqual (
218
+ assert . deepEqual (
218
219
removePosition (
219
220
fromMarkdown ( '<<<\na\n\nb\n>>>' , {
220
221
extensions : [ frontmatter ( custom ) ] ,
@@ -226,7 +227,7 @@ test('markdown -> mdast', (t) => {
226
227
'should support a custom matter (1)'
227
228
)
228
229
229
- t . deepEqual (
230
+ assert . deepEqual (
230
231
removePosition (
231
232
fromMarkdown ( '{\na\n\nb\n}' , {
232
233
extensions : [ frontmatter ( json ) ] ,
@@ -238,7 +239,7 @@ test('markdown -> mdast', (t) => {
238
239
'should support a custom matter (2)'
239
240
)
240
241
241
- t . deepEqual (
242
+ assert . deepEqual (
242
243
removePosition (
243
244
fromMarkdown ( '# Hello\n---\na\n\nb\n---\n+++' , {
244
245
extensions : [ frontmatter ( ) ] ,
@@ -259,7 +260,7 @@ test('markdown -> mdast', (t) => {
259
260
'should not support yaml frontmatter in the middle'
260
261
)
261
262
262
- t . deepEqual (
263
+ assert . deepEqual (
263
264
removePosition (
264
265
fromMarkdown ( '# Hello\n---\na\n\nb\n---\n+++' , {
265
266
extensions : [ frontmatter ( yamlAnywhere ) ] ,
@@ -277,12 +278,10 @@ test('markdown -> mdast', (t) => {
277
278
} ,
278
279
'should not support custom matters in the middle'
279
280
)
280
-
281
- t . end ( )
282
281
} )
283
282
284
- test ( 'mdast -> markdown ' , ( t ) => {
285
- t . deepEqual (
283
+ test ( 'frontmatterToMarkdown ' , ( ) => {
284
+ assert . deepEqual (
286
285
toMarkdown (
287
286
{ type : 'root' , children : [ { type : 'yaml' , value : '' } ] } ,
288
287
{ extensions : [ frontmatterToMarkdown ( ) ] }
@@ -291,7 +290,7 @@ test('mdast -> markdown', (t) => {
291
290
'should serialize empty yaml'
292
291
)
293
292
294
- t . deepEqual (
293
+ assert . deepEqual (
295
294
toMarkdown (
296
295
{ type : 'root' , children : [ { type : 'yaml' , value : 'a\nb' } ] } ,
297
296
{ extensions : [ frontmatterToMarkdown ( ) ] }
@@ -300,7 +299,7 @@ test('mdast -> markdown', (t) => {
300
299
'should support content in yaml'
301
300
)
302
301
303
- t . deepEqual (
302
+ assert . deepEqual (
304
303
toMarkdown (
305
304
{ type : 'root' , children : [ { type : 'yaml' , value : 'a\n\nb' } ] } ,
306
305
{ extensions : [ frontmatterToMarkdown ( ) ] }
@@ -309,7 +308,7 @@ test('mdast -> markdown', (t) => {
309
308
'should support blank lines in yaml'
310
309
)
311
310
312
- t . deepEqual (
311
+ assert . deepEqual (
313
312
toMarkdown (
314
313
{ type : 'root' , children : [ { type : 'toml' , value : 'a\n\nb' } ] } ,
315
314
{ extensions : [ frontmatterToMarkdown ( 'toml' ) ] }
@@ -318,7 +317,7 @@ test('mdast -> markdown', (t) => {
318
317
'should support blank lines in yaml'
319
318
)
320
319
321
- t . deepEqual (
320
+ assert . deepEqual (
322
321
toMarkdown (
323
322
{ type : 'root' , children : [ { type : 'custom' , value : 'a\n\nb' } ] } ,
324
323
{ extensions : [ frontmatterToMarkdown ( custom ) ] }
@@ -327,7 +326,7 @@ test('mdast -> markdown', (t) => {
327
326
'should support a custom matter (1)'
328
327
)
329
328
330
- t . deepEqual (
329
+ assert . deepEqual (
331
330
toMarkdown (
332
331
{ type : 'root' , children : [ { type : 'json' , value : 'a\n\nb' } ] } ,
333
332
{ extensions : [ frontmatterToMarkdown ( json ) ] }
@@ -336,14 +335,12 @@ test('mdast -> markdown', (t) => {
336
335
'should support a custom matter (2)'
337
336
)
338
337
339
- t . deepEqual (
338
+ assert . deepEqual (
340
339
toMarkdown (
341
340
{ type : 'root' , children : [ { type : 'text' , value : '<<<\na\n\nb\n>>>' } ] } ,
342
341
{ extensions : [ frontmatterToMarkdown ( custom ) ] }
343
342
) ,
344
343
'\\<<<\na\n\nb\n\\>>>\n' ,
345
344
'should escape what would otherwise be custom matter'
346
345
)
347
-
348
- t . end ( )
349
346
} )
0 commit comments