1
- import test from 'tape'
1
+ import assert from 'node:assert/strict'
2
+ import test from 'node:test'
2
3
import { fromMarkdown } from 'mdast-util-from-markdown'
3
4
import { toMarkdown } from 'mdast-util-to-markdown'
4
5
import { math } from 'micromark-extension-math'
5
6
import { mathFromMarkdown , mathToMarkdown } from './index.js'
6
7
7
- test ( 'markdown -> mdast ' , ( t ) => {
8
- t . deepEqual (
8
+ test ( 'mathFromMarkdown ' , ( ) => {
9
+ assert . deepEqual (
9
10
fromMarkdown ( 'a $b$ c' , {
10
11
extensions : [ math ( ) ] ,
11
12
mdastExtensions : [ mathFromMarkdown ( ) ]
@@ -60,7 +61,7 @@ test('markdown -> mdast', (t) => {
60
61
'should support math (text)'
61
62
)
62
63
63
- t . deepEqual (
64
+ assert . deepEqual (
64
65
fromMarkdown ( '$$\na\n$$' , {
65
66
extensions : [ math ( ) ] ,
66
67
mdastExtensions : [ mathFromMarkdown ( ) ]
@@ -82,7 +83,7 @@ test('markdown -> mdast', (t) => {
82
83
'should support math (flow)'
83
84
)
84
85
85
- t . deepEqual (
86
+ assert . deepEqual (
86
87
fromMarkdown ( '$$a&b\\&c\n' , {
87
88
extensions : [ math ( ) ] ,
88
89
mdastExtensions : [ mathFromMarkdown ( ) ]
@@ -104,7 +105,7 @@ test('markdown -> mdast', (t) => {
104
105
'should support math (flow) w/ meta'
105
106
)
106
107
107
- t . deepEqual (
108
+ assert . deepEqual (
108
109
fromMarkdown ( '$a\nb\nb$' , {
109
110
extensions : [ math ( ) ] ,
110
111
mdastExtensions : [ mathFromMarkdown ( ) ]
@@ -133,12 +134,10 @@ test('markdown -> mdast', (t) => {
133
134
} ,
134
135
'should support math (text) w/ EOLs'
135
136
)
136
-
137
- t . end ( )
138
137
} )
139
138
140
- test ( 'mdast -> markdown ' , ( t ) => {
141
- t . deepEqual (
139
+ test ( 'mathToMarkdown ' , ( ) => {
140
+ assert . deepEqual (
142
141
toMarkdown (
143
142
{ type : 'inlineMath' , value : 'a' } ,
144
143
{ extensions : [ mathToMarkdown ( ) ] }
@@ -147,7 +146,7 @@ test('mdast -> markdown', (t) => {
147
146
'should serialize math (text)'
148
147
)
149
148
150
- t . deepEqual (
149
+ assert . deepEqual (
151
150
toMarkdown (
152
151
{ type : 'inlineMath' , value : 'a' } ,
153
152
{ extensions : [ mathToMarkdown ( { singleDollarTextMath : false } ) ] }
@@ -156,14 +155,14 @@ test('mdast -> markdown', (t) => {
156
155
'should serialize math (text) with at least 2 dollars w/ `singleDollarTextMath: false`'
157
156
)
158
157
159
- t . deepEqual (
158
+ assert . deepEqual (
160
159
// @ts -expect-error: `value` missing.
161
160
toMarkdown ( { type : 'inlineMath' } , { extensions : [ mathToMarkdown ( ) ] } ) ,
162
161
'$$\n' ,
163
162
'should serialize math (text) w/o `value`'
164
163
)
165
164
166
- t . deepEqual (
165
+ assert . deepEqual (
167
166
toMarkdown (
168
167
{ type : 'inlineMath' , value : 'a \\$ b' } ,
169
168
{ extensions : [ mathToMarkdown ( ) ] }
@@ -172,7 +171,7 @@ test('mdast -> markdown', (t) => {
172
171
'should serialize math (text) w/ two dollar signs when including a dollar'
173
172
)
174
173
175
- t . deepEqual (
174
+ assert . deepEqual (
176
175
toMarkdown (
177
176
{ type : 'inlineMath' , value : 'a \\$' } ,
178
177
{ extensions : [ mathToMarkdown ( ) ] }
@@ -181,7 +180,7 @@ test('mdast -> markdown', (t) => {
181
180
'should serialize math (text) w/ padding when ending in a dollar sign'
182
181
)
183
182
184
- t . deepEqual (
183
+ assert . deepEqual (
185
184
toMarkdown (
186
185
{ type : 'inlineMath' , value : '$ a' } ,
187
186
{ extensions : [ mathToMarkdown ( ) ] }
@@ -190,7 +189,7 @@ test('mdast -> markdown', (t) => {
190
189
'should serialize math (text) w/ padding when starting in a dollar sign'
191
190
)
192
191
193
- t . equal (
192
+ assert . equal (
194
193
toMarkdown (
195
194
{ type : 'inlineMath' , value : ' a ' } ,
196
195
{ extensions : [ mathToMarkdown ( ) ] }
@@ -199,7 +198,7 @@ test('mdast -> markdown', (t) => {
199
198
'should pad w/ a space if the value starts and ends w/ a space'
200
199
)
201
200
202
- t . equal (
201
+ assert . equal (
203
202
toMarkdown (
204
203
{ type : 'inlineMath' , value : ' a' } ,
205
204
{ extensions : [ mathToMarkdown ( ) ] }
@@ -208,7 +207,7 @@ test('mdast -> markdown', (t) => {
208
207
'should not pad w/ spaces if the value ends w/ a non-space'
209
208
)
210
209
211
- t . equal (
210
+ assert . equal (
212
211
toMarkdown (
213
212
{ type : 'inlineMath' , value : 'a ' } ,
214
213
{ extensions : [ mathToMarkdown ( ) ] }
@@ -217,40 +216,40 @@ test('mdast -> markdown', (t) => {
217
216
'should not pad w/ spaces if the value starts w/ a non-space'
218
217
)
219
218
220
- t . deepEqual (
219
+ assert . deepEqual (
221
220
toMarkdown ( { type : 'math' , value : 'a' } , { extensions : [ mathToMarkdown ( ) ] } ) ,
222
221
'$$\na\n$$\n' ,
223
222
'should serialize math (flow)'
224
223
)
225
224
226
- t . deepEqual (
225
+ assert . deepEqual (
227
226
// @ts -expect-error: `value` missing.
228
227
toMarkdown ( { type : 'math' } , { extensions : [ mathToMarkdown ( ) ] } ) ,
229
228
'$$\n$$\n' ,
230
229
'should serialize math (flow) w/o `value`'
231
230
)
232
231
233
- t . deepEqual (
232
+ assert . deepEqual (
234
233
// @ts -expect-error: `value` missing.
235
234
toMarkdown ( { type : 'math' , meta : 'a' } , { extensions : [ mathToMarkdown ( ) ] } ) ,
236
235
'$$a\n$$\n' ,
237
236
'should serialize math (flow) w/ `meta`'
238
237
)
239
238
240
- t . deepEqual (
239
+ assert . deepEqual (
241
240
toMarkdown ( { type : 'math' , value : '$$' } , { extensions : [ mathToMarkdown ( ) ] } ) ,
242
241
'$$$\n$$\n$$$\n' ,
243
242
'should serialize math (flow) w/ more dollars than occur together in `value`'
244
243
)
245
244
246
- t . deepEqual (
245
+ assert . deepEqual (
247
246
// @ts -expect-error: `value` missing.
248
247
toMarkdown ( { type : 'math' , meta : 'a' } , { extensions : [ mathToMarkdown ( ) ] } ) ,
249
248
'$$a\n$$\n' ,
250
249
'should serialize math (flow) w/ `meta`'
251
250
)
252
251
253
- t . deepEqual (
252
+ assert . deepEqual (
254
253
toMarkdown (
255
254
{ type : 'paragraph' , children : [ { type : 'text' , value : 'a $ b' } ] } ,
256
255
{ extensions : [ mathToMarkdown ( ) ] }
@@ -259,7 +258,7 @@ test('mdast -> markdown', (t) => {
259
258
'should escape `$` in phrasing'
260
259
)
261
260
262
- t . deepEqual (
261
+ assert . deepEqual (
263
262
toMarkdown (
264
263
{ type : 'paragraph' , children : [ { type : 'text' , value : 'a $ b' } ] } ,
265
264
{ extensions : [ mathToMarkdown ( { singleDollarTextMath : false } ) ] }
@@ -268,7 +267,7 @@ test('mdast -> markdown', (t) => {
268
267
'should not escape a single dollar in phrasing w/ `singleDollarTextMath: false`'
269
268
)
270
269
271
- t . deepEqual (
270
+ assert . deepEqual (
272
271
toMarkdown (
273
272
{ type : 'paragraph' , children : [ { type : 'text' , value : 'a $$ b' } ] } ,
274
273
{ extensions : [ mathToMarkdown ( { singleDollarTextMath : false } ) ] }
@@ -277,7 +276,7 @@ test('mdast -> markdown', (t) => {
277
276
'should escape two dollars in phrasing w/ `singleDollarTextMath: false`'
278
277
)
279
278
280
- t . deepEqual (
279
+ assert . deepEqual (
281
280
toMarkdown (
282
281
{
283
282
type : 'paragraph' ,
@@ -293,7 +292,7 @@ test('mdast -> markdown', (t) => {
293
292
'should escape `$` around math (text)'
294
293
)
295
294
296
- t . deepEqual (
295
+ assert . deepEqual (
297
296
toMarkdown (
298
297
{
299
298
type : 'definition' ,
@@ -308,7 +307,7 @@ test('mdast -> markdown', (t) => {
308
307
'should not escape `$` at the start of a line'
309
308
)
310
309
311
- t . deepEqual (
310
+ assert . deepEqual (
312
311
toMarkdown (
313
312
{ type : 'math' , meta : 'a\rb\nc' , value : '' } ,
314
313
{ extensions : [ mathToMarkdown ( ) ] }
@@ -317,7 +316,7 @@ test('mdast -> markdown', (t) => {
317
316
'should escape `\\r`, `\\n` when in `meta` of math (flow)'
318
317
)
319
318
320
- t . deepEqual (
319
+ assert . deepEqual (
321
320
toMarkdown (
322
321
{ type : 'math' , meta : 'a$b' , value : '' } ,
323
322
{ extensions : [ mathToMarkdown ( ) ] }
@@ -326,7 +325,7 @@ test('mdast -> markdown', (t) => {
326
325
'should escape `$` when in `meta` of math (flow)'
327
326
)
328
327
329
- t . equal (
328
+ assert . equal (
330
329
toMarkdown (
331
330
{ type : 'inlineMath' , value : 'a\n- b' } ,
332
331
{ extensions : [ mathToMarkdown ( ) ] }
@@ -335,7 +334,7 @@ test('mdast -> markdown', (t) => {
335
334
'should prevent breaking out of code (-)'
336
335
)
337
336
338
- t . equal (
337
+ assert . equal (
339
338
toMarkdown (
340
339
{ type : 'inlineMath' , value : 'a\n#' } ,
341
340
{ extensions : [ mathToMarkdown ( ) ] }
@@ -344,7 +343,7 @@ test('mdast -> markdown', (t) => {
344
343
'should prevent breaking out of code (#)'
345
344
)
346
345
347
- t . equal (
346
+ assert . equal (
348
347
toMarkdown (
349
348
{ type : 'inlineMath' , value : 'a\n1. ' } ,
350
349
{ extensions : [ mathToMarkdown ( ) ] }
@@ -353,7 +352,7 @@ test('mdast -> markdown', (t) => {
353
352
'should prevent breaking out of code (\\d\\.)'
354
353
)
355
354
356
- t . equal (
355
+ assert . equal (
357
356
toMarkdown (
358
357
{ type : 'inlineMath' , value : 'a\r- b' } ,
359
358
{ extensions : [ mathToMarkdown ( ) ] }
@@ -362,14 +361,12 @@ test('mdast -> markdown', (t) => {
362
361
'should prevent breaking out of code (cr)'
363
362
)
364
363
365
- t . equal (
364
+ assert . equal (
366
365
toMarkdown (
367
366
{ type : 'inlineMath' , value : 'a\r\n- b' } ,
368
367
{ extensions : [ mathToMarkdown ( ) ] }
369
368
) ,
370
369
'$a - b$\n' ,
371
370
'should prevent breaking out of code (crlf)'
372
371
)
373
-
374
- t . end ( )
375
372
} )
0 commit comments