1- import test from 'tape'
1+ import assert from 'node:assert/strict'
2+ import test from 'node:test'
23import { fromMarkdown } from 'mdast-util-from-markdown'
34import { toMarkdown } from 'mdast-util-to-markdown'
45import { math } from 'micromark-extension-math'
56import { mathFromMarkdown , mathToMarkdown } from './index.js'
67
7- test ( 'markdown -> mdast ' , ( t ) => {
8- t . deepEqual (
8+ test ( 'mathFromMarkdown ' , ( ) => {
9+ assert . deepEqual (
910 fromMarkdown ( 'a $b$ c' , {
1011 extensions : [ math ( ) ] ,
1112 mdastExtensions : [ mathFromMarkdown ( ) ]
@@ -60,7 +61,7 @@ test('markdown -> mdast', (t) => {
6061 'should support math (text)'
6162 )
6263
63- t . deepEqual (
64+ assert . deepEqual (
6465 fromMarkdown ( '$$\na\n$$' , {
6566 extensions : [ math ( ) ] ,
6667 mdastExtensions : [ mathFromMarkdown ( ) ]
@@ -82,7 +83,7 @@ test('markdown -> mdast', (t) => {
8283 'should support math (flow)'
8384 )
8485
85- t . deepEqual (
86+ assert . deepEqual (
8687 fromMarkdown ( '$$a&b\\&c\n' , {
8788 extensions : [ math ( ) ] ,
8889 mdastExtensions : [ mathFromMarkdown ( ) ]
@@ -104,7 +105,7 @@ test('markdown -> mdast', (t) => {
104105 'should support math (flow) w/ meta'
105106 )
106107
107- t . deepEqual (
108+ assert . deepEqual (
108109 fromMarkdown ( '$a\nb\nb$' , {
109110 extensions : [ math ( ) ] ,
110111 mdastExtensions : [ mathFromMarkdown ( ) ]
@@ -133,12 +134,10 @@ test('markdown -> mdast', (t) => {
133134 } ,
134135 'should support math (text) w/ EOLs'
135136 )
136-
137- t . end ( )
138137} )
139138
140- test ( 'mdast -> markdown ' , ( t ) => {
141- t . deepEqual (
139+ test ( 'mathToMarkdown ' , ( ) => {
140+ assert . deepEqual (
142141 toMarkdown (
143142 { type : 'inlineMath' , value : 'a' } ,
144143 { extensions : [ mathToMarkdown ( ) ] }
@@ -147,7 +146,7 @@ test('mdast -> markdown', (t) => {
147146 'should serialize math (text)'
148147 )
149148
150- t . deepEqual (
149+ assert . deepEqual (
151150 toMarkdown (
152151 { type : 'inlineMath' , value : 'a' } ,
153152 { extensions : [ mathToMarkdown ( { singleDollarTextMath : false } ) ] }
@@ -156,14 +155,14 @@ test('mdast -> markdown', (t) => {
156155 'should serialize math (text) with at least 2 dollars w/ `singleDollarTextMath: false`'
157156 )
158157
159- t . deepEqual (
158+ assert . deepEqual (
160159 // @ts -expect-error: `value` missing.
161160 toMarkdown ( { type : 'inlineMath' } , { extensions : [ mathToMarkdown ( ) ] } ) ,
162161 '$$\n' ,
163162 'should serialize math (text) w/o `value`'
164163 )
165164
166- t . deepEqual (
165+ assert . deepEqual (
167166 toMarkdown (
168167 { type : 'inlineMath' , value : 'a \\$ b' } ,
169168 { extensions : [ mathToMarkdown ( ) ] }
@@ -172,7 +171,7 @@ test('mdast -> markdown', (t) => {
172171 'should serialize math (text) w/ two dollar signs when including a dollar'
173172 )
174173
175- t . deepEqual (
174+ assert . deepEqual (
176175 toMarkdown (
177176 { type : 'inlineMath' , value : 'a \\$' } ,
178177 { extensions : [ mathToMarkdown ( ) ] }
@@ -181,7 +180,7 @@ test('mdast -> markdown', (t) => {
181180 'should serialize math (text) w/ padding when ending in a dollar sign'
182181 )
183182
184- t . deepEqual (
183+ assert . deepEqual (
185184 toMarkdown (
186185 { type : 'inlineMath' , value : '$ a' } ,
187186 { extensions : [ mathToMarkdown ( ) ] }
@@ -190,7 +189,7 @@ test('mdast -> markdown', (t) => {
190189 'should serialize math (text) w/ padding when starting in a dollar sign'
191190 )
192191
193- t . equal (
192+ assert . equal (
194193 toMarkdown (
195194 { type : 'inlineMath' , value : ' a ' } ,
196195 { extensions : [ mathToMarkdown ( ) ] }
@@ -199,7 +198,7 @@ test('mdast -> markdown', (t) => {
199198 'should pad w/ a space if the value starts and ends w/ a space'
200199 )
201200
202- t . equal (
201+ assert . equal (
203202 toMarkdown (
204203 { type : 'inlineMath' , value : ' a' } ,
205204 { extensions : [ mathToMarkdown ( ) ] }
@@ -208,7 +207,7 @@ test('mdast -> markdown', (t) => {
208207 'should not pad w/ spaces if the value ends w/ a non-space'
209208 )
210209
211- t . equal (
210+ assert . equal (
212211 toMarkdown (
213212 { type : 'inlineMath' , value : 'a ' } ,
214213 { extensions : [ mathToMarkdown ( ) ] }
@@ -217,40 +216,40 @@ test('mdast -> markdown', (t) => {
217216 'should not pad w/ spaces if the value starts w/ a non-space'
218217 )
219218
220- t . deepEqual (
219+ assert . deepEqual (
221220 toMarkdown ( { type : 'math' , value : 'a' } , { extensions : [ mathToMarkdown ( ) ] } ) ,
222221 '$$\na\n$$\n' ,
223222 'should serialize math (flow)'
224223 )
225224
226- t . deepEqual (
225+ assert . deepEqual (
227226 // @ts -expect-error: `value` missing.
228227 toMarkdown ( { type : 'math' } , { extensions : [ mathToMarkdown ( ) ] } ) ,
229228 '$$\n$$\n' ,
230229 'should serialize math (flow) w/o `value`'
231230 )
232231
233- t . deepEqual (
232+ assert . deepEqual (
234233 // @ts -expect-error: `value` missing.
235234 toMarkdown ( { type : 'math' , meta : 'a' } , { extensions : [ mathToMarkdown ( ) ] } ) ,
236235 '$$a\n$$\n' ,
237236 'should serialize math (flow) w/ `meta`'
238237 )
239238
240- t . deepEqual (
239+ assert . deepEqual (
241240 toMarkdown ( { type : 'math' , value : '$$' } , { extensions : [ mathToMarkdown ( ) ] } ) ,
242241 '$$$\n$$\n$$$\n' ,
243242 'should serialize math (flow) w/ more dollars than occur together in `value`'
244243 )
245244
246- t . deepEqual (
245+ assert . deepEqual (
247246 // @ts -expect-error: `value` missing.
248247 toMarkdown ( { type : 'math' , meta : 'a' } , { extensions : [ mathToMarkdown ( ) ] } ) ,
249248 '$$a\n$$\n' ,
250249 'should serialize math (flow) w/ `meta`'
251250 )
252251
253- t . deepEqual (
252+ assert . deepEqual (
254253 toMarkdown (
255254 { type : 'paragraph' , children : [ { type : 'text' , value : 'a $ b' } ] } ,
256255 { extensions : [ mathToMarkdown ( ) ] }
@@ -259,7 +258,7 @@ test('mdast -> markdown', (t) => {
259258 'should escape `$` in phrasing'
260259 )
261260
262- t . deepEqual (
261+ assert . deepEqual (
263262 toMarkdown (
264263 { type : 'paragraph' , children : [ { type : 'text' , value : 'a $ b' } ] } ,
265264 { extensions : [ mathToMarkdown ( { singleDollarTextMath : false } ) ] }
@@ -268,7 +267,7 @@ test('mdast -> markdown', (t) => {
268267 'should not escape a single dollar in phrasing w/ `singleDollarTextMath: false`'
269268 )
270269
271- t . deepEqual (
270+ assert . deepEqual (
272271 toMarkdown (
273272 { type : 'paragraph' , children : [ { type : 'text' , value : 'a $$ b' } ] } ,
274273 { extensions : [ mathToMarkdown ( { singleDollarTextMath : false } ) ] }
@@ -277,7 +276,7 @@ test('mdast -> markdown', (t) => {
277276 'should escape two dollars in phrasing w/ `singleDollarTextMath: false`'
278277 )
279278
280- t . deepEqual (
279+ assert . deepEqual (
281280 toMarkdown (
282281 {
283282 type : 'paragraph' ,
@@ -293,7 +292,7 @@ test('mdast -> markdown', (t) => {
293292 'should escape `$` around math (text)'
294293 )
295294
296- t . deepEqual (
295+ assert . deepEqual (
297296 toMarkdown (
298297 {
299298 type : 'definition' ,
@@ -308,7 +307,7 @@ test('mdast -> markdown', (t) => {
308307 'should not escape `$` at the start of a line'
309308 )
310309
311- t . deepEqual (
310+ assert . deepEqual (
312311 toMarkdown (
313312 { type : 'math' , meta : 'a\rb\nc' , value : '' } ,
314313 { extensions : [ mathToMarkdown ( ) ] }
@@ -317,7 +316,7 @@ test('mdast -> markdown', (t) => {
317316 'should escape `\\r`, `\\n` when in `meta` of math (flow)'
318317 )
319318
320- t . deepEqual (
319+ assert . deepEqual (
321320 toMarkdown (
322321 { type : 'math' , meta : 'a$b' , value : '' } ,
323322 { extensions : [ mathToMarkdown ( ) ] }
@@ -326,7 +325,7 @@ test('mdast -> markdown', (t) => {
326325 'should escape `$` when in `meta` of math (flow)'
327326 )
328327
329- t . equal (
328+ assert . equal (
330329 toMarkdown (
331330 { type : 'inlineMath' , value : 'a\n- b' } ,
332331 { extensions : [ mathToMarkdown ( ) ] }
@@ -335,7 +334,7 @@ test('mdast -> markdown', (t) => {
335334 'should prevent breaking out of code (-)'
336335 )
337336
338- t . equal (
337+ assert . equal (
339338 toMarkdown (
340339 { type : 'inlineMath' , value : 'a\n#' } ,
341340 { extensions : [ mathToMarkdown ( ) ] }
@@ -344,7 +343,7 @@ test('mdast -> markdown', (t) => {
344343 'should prevent breaking out of code (#)'
345344 )
346345
347- t . equal (
346+ assert . equal (
348347 toMarkdown (
349348 { type : 'inlineMath' , value : 'a\n1. ' } ,
350349 { extensions : [ mathToMarkdown ( ) ] }
@@ -353,7 +352,7 @@ test('mdast -> markdown', (t) => {
353352 'should prevent breaking out of code (\\d\\.)'
354353 )
355354
356- t . equal (
355+ assert . equal (
357356 toMarkdown (
358357 { type : 'inlineMath' , value : 'a\r- b' } ,
359358 { extensions : [ mathToMarkdown ( ) ] }
@@ -362,14 +361,12 @@ test('mdast -> markdown', (t) => {
362361 'should prevent breaking out of code (cr)'
363362 )
364363
365- t . equal (
364+ assert . equal (
366365 toMarkdown (
367366 { type : 'inlineMath' , value : 'a\r\n- b' } ,
368367 { extensions : [ mathToMarkdown ( ) ] }
369368 ) ,
370369 '$a - b$\n' ,
371370 'should prevent breaking out of code (crlf)'
372371 )
373-
374- t . end ( )
375372} )
0 commit comments