@@ -29,56 +29,59 @@ test('markdown -> mdast', (t) => {
29
29
type : 'Program' ,
30
30
start : 0 ,
31
31
end : 17 ,
32
- loc : { start : { line : 1 , column : 0 } , end : { line : 1 , column : 17 } } ,
33
32
body : [
34
33
{
35
34
type : 'ImportDeclaration' ,
36
35
start : 0 ,
37
36
end : 17 ,
38
- loc : {
39
- start : { line : 1 , column : 0 } ,
40
- end : { line : 1 , column : 17 }
41
- } ,
42
37
specifiers : [
43
38
{
44
39
type : 'ImportDefaultSpecifier' ,
45
40
start : 7 ,
46
41
end : 8 ,
47
- loc : {
48
- start : { line : 1 , column : 7 } ,
49
- end : { line : 1 , column : 8 }
50
- } ,
51
42
local : {
52
43
type : 'Identifier' ,
53
44
start : 7 ,
54
45
end : 8 ,
46
+ name : 'a' ,
55
47
loc : {
56
- start : { line : 1 , column : 7 } ,
57
- end : { line : 1 , column : 8 }
48
+ start : { line : 1 , column : 7 , offset : 7 } ,
49
+ end : { line : 1 , column : 8 , offset : 8 }
58
50
} ,
59
- name : 'a' ,
60
51
range : [ 7 , 8 ]
61
52
} ,
53
+ loc : {
54
+ start : { line : 1 , column : 7 , offset : 7 } ,
55
+ end : { line : 1 , column : 8 , offset : 8 }
56
+ } ,
62
57
range : [ 7 , 8 ]
63
58
}
64
59
] ,
65
60
source : {
66
61
type : 'Literal' ,
67
62
start : 14 ,
68
63
end : 17 ,
69
- loc : {
70
- start : { line : 1 , column : 14 } ,
71
- end : { line : 1 , column : 17 }
72
- } ,
73
64
value : 'b' ,
74
65
raw : '"b"' ,
66
+ loc : {
67
+ start : { line : 1 , column : 14 , offset : 14 } ,
68
+ end : { line : 1 , column : 17 , offset : 17 }
69
+ } ,
75
70
range : [ 14 , 17 ]
76
71
} ,
72
+ loc : {
73
+ start : { line : 1 , column : 0 , offset : 0 } ,
74
+ end : { line : 1 , column : 17 , offset : 17 }
75
+ } ,
77
76
range : [ 0 , 17 ]
78
77
}
79
78
] ,
80
79
sourceType : 'module' ,
81
80
comments : [ ] ,
81
+ loc : {
82
+ start : { line : 1 , column : 0 , offset : 0 } ,
83
+ end : { line : 1 , column : 17 , offset : 17 }
84
+ } ,
82
85
range : [ 0 , 17 ]
83
86
}
84
87
}
@@ -157,8 +160,8 @@ test('markdown -> mdast', (t) => {
157
160
value : 1 ,
158
161
raw : '1' ,
159
162
loc : {
160
- start : { line : 1 , column : 1 } ,
161
- end : { line : 1 , column : 2 }
163
+ start : { line : 1 , column : 1 , offset : 1 } ,
164
+ end : { line : 1 , column : 2 , offset : 2 }
162
165
} ,
163
166
range : [ 1 , 2 ]
164
167
} ,
@@ -170,26 +173,32 @@ test('markdown -> mdast', (t) => {
170
173
value : 1 ,
171
174
raw : '1' ,
172
175
loc : {
173
- start : { line : 1 , column : 5 } ,
174
- end : { line : 1 , column : 6 }
176
+ start : { line : 1 , column : 5 , offset : 5 } ,
177
+ end : { line : 1 , column : 6 , offset : 6 }
175
178
} ,
176
179
range : [ 5 , 6 ]
177
180
} ,
178
181
loc : {
179
- start : { line : 1 , column : 1 } ,
180
- end : { line : 1 , column : 6 }
182
+ start : { line : 1 , column : 1 , offset : 1 } ,
183
+ end : { line : 1 , column : 6 , offset : 6 }
181
184
} ,
182
185
range : [ 1 , 6 ]
183
186
} ,
184
187
start : 1 ,
185
188
end : 6 ,
186
- loc : { start : { line : 1 , column : 1 } , end : { line : 1 , column : 6 } } ,
189
+ loc : {
190
+ start : { line : 1 , column : 1 , offset : 1 } ,
191
+ end : { line : 1 , column : 6 , offset : 6 }
192
+ } ,
187
193
range : [ 1 , 6 ]
188
194
}
189
195
] ,
190
196
sourceType : 'module' ,
191
197
comments : [ ] ,
192
- loc : { start : { line : 1 , column : 1 } , end : { line : 1 , column : 6 } } ,
198
+ loc : {
199
+ start : { line : 1 , column : 1 , offset : 1 } ,
200
+ end : { line : 1 , column : 6 , offset : 6 }
201
+ } ,
193
202
range : [ 1 , 6 ]
194
203
}
195
204
}
@@ -207,11 +216,7 @@ test('markdown -> mdast', (t) => {
207
216
JSON . parse (
208
217
JSON . stringify (
209
218
fromMarkdown (
210
- `<Stuff>
211
- {{
212
- template: /* Comment */ '',
213
- }}
214
- </Stuff>` ,
219
+ "<Stuff>\n {{\n template: /* Comment */ '',\n }}\n</Stuff>" ,
215
220
{
216
221
extensions : [ mdxjs ( ) ] ,
217
222
mdastExtensions : [ mdxFromMarkdown ( ) ]
@@ -260,8 +265,8 @@ test('markdown -> mdast', (t) => {
260
265
end : 25 ,
261
266
name : 'template' ,
262
267
loc : {
263
- start : { line : 3 , column : 4 } ,
264
- end : { line : 3 , column : 12 }
268
+ start : { line : 3 , column : 4 , offset : 17 } ,
269
+ end : { line : 3 , column : 12 , offset : 25 }
265
270
} ,
266
271
range : [ 17 , 25 ]
267
272
} ,
@@ -272,30 +277,30 @@ test('markdown -> mdast', (t) => {
272
277
value : '' ,
273
278
raw : "''" ,
274
279
loc : {
275
- start : { line : 3 , column : 28 } ,
276
- end : { line : 3 , column : 30 }
280
+ start : { line : 3 , column : 28 , offset : 41 } ,
281
+ end : { line : 3 , column : 30 , offset : 43 }
277
282
} ,
278
283
range : [ 41 , 43 ]
279
284
} ,
280
285
kind : 'init' ,
281
286
loc : {
282
- start : { line : 3 , column : 4 } ,
283
- end : { line : 3 , column : 30 }
287
+ start : { line : 3 , column : 4 , offset : 17 } ,
288
+ end : { line : 3 , column : 30 , offset : 43 }
284
289
} ,
285
290
range : [ 17 , 43 ]
286
291
}
287
292
] ,
288
293
loc : {
289
- start : { line : 2 , column : 3 } ,
290
- end : { line : 4 , column : 3 }
294
+ start : { line : 2 , column : 3 , offset : 11 } ,
295
+ end : { line : 4 , column : 3 , offset : 48 }
291
296
} ,
292
297
range : [ 11 , 48 ]
293
298
} ,
294
299
start : 11 ,
295
300
end : 48 ,
296
301
loc : {
297
- start : { line : 2 , column : 3 } ,
298
- end : { line : 4 , column : 3 }
302
+ start : { line : 2 , column : 3 , offset : 11 } ,
303
+ end : { line : 4 , column : 3 , offset : 48 }
299
304
} ,
300
305
range : [ 11 , 48 ]
301
306
}
@@ -308,15 +313,15 @@ test('markdown -> mdast', (t) => {
308
313
start : 27 ,
309
314
end : 40 ,
310
315
loc : {
311
- start : { line : 3 , column : 14 } ,
312
- end : { line : 3 , column : 27 }
316
+ start : { line : 3 , column : 14 , offset : 27 } ,
317
+ end : { line : 3 , column : 27 , offset : 40 }
313
318
} ,
314
319
range : [ 27 , 40 ]
315
320
}
316
321
] ,
317
322
loc : {
318
- start : { line : 2 , column : 3 } ,
319
- end : { line : 4 , column : 3 }
323
+ start : { line : 2 , column : 3 , offset : 11 } ,
324
+ end : { line : 4 , column : 3 , offset : 48 }
320
325
} ,
321
326
range : [ 11 , 48 ]
322
327
}
@@ -340,12 +345,10 @@ test('markdown -> mdast', (t) => {
340
345
t . deepEqual (
341
346
JSON . parse (
342
347
JSON . stringify (
343
- fromMarkdown (
344
- `export let a = 'a'
345
-
346
- export let b = 'b'` ,
347
- { extensions : [ mdxjs ( ) ] , mdastExtensions : [ mdxFromMarkdown ( ) ] }
348
- )
348
+ fromMarkdown ( "export let a = 'a'\n\nexport let b = 'b'" , {
349
+ extensions : [ mdxjs ( ) ] ,
350
+ mdastExtensions : [ mdxFromMarkdown ( ) ]
351
+ } )
349
352
)
350
353
) ,
351
354
{
@@ -383,8 +386,8 @@ export let b = 'b'`,
383
386
end : 12 ,
384
387
name : 'a' ,
385
388
loc : {
386
- start : { line : 1 , column : 11 } ,
387
- end : { line : 1 , column : 12 }
389
+ start : { line : 1 , column : 11 , offset : 11 } ,
390
+ end : { line : 1 , column : 12 , offset : 12 }
388
391
} ,
389
392
range : [ 11 , 12 ]
390
393
} ,
@@ -395,39 +398,39 @@ export let b = 'b'`,
395
398
value : 'a' ,
396
399
raw : "'a'" ,
397
400
loc : {
398
- start : { line : 1 , column : 15 } ,
399
- end : { line : 1 , column : 18 }
401
+ start : { line : 1 , column : 15 , offset : 15 } ,
402
+ end : { line : 1 , column : 18 , offset : 18 }
400
403
} ,
401
404
range : [ 15 , 18 ]
402
405
} ,
403
406
loc : {
404
- start : { line : 1 , column : 11 } ,
405
- end : { line : 1 , column : 18 }
407
+ start : { line : 1 , column : 11 , offset : 11 } ,
408
+ end : { line : 1 , column : 18 , offset : 18 }
406
409
} ,
407
410
range : [ 11 , 18 ]
408
411
}
409
412
] ,
410
413
kind : 'let' ,
411
414
loc : {
412
- start : { line : 1 , column : 7 } ,
413
- end : { line : 1 , column : 18 }
415
+ start : { line : 1 , column : 7 , offset : 7 } ,
416
+ end : { line : 1 , column : 18 , offset : 18 }
414
417
} ,
415
418
range : [ 7 , 18 ]
416
419
} ,
417
420
specifiers : [ ] ,
418
421
source : null ,
419
422
loc : {
420
- start : { line : 1 , column : 0 } ,
421
- end : { line : 1 , column : 18 }
423
+ start : { line : 1 , column : 0 , offset : 0 } ,
424
+ end : { line : 1 , column : 18 , offset : 18 }
422
425
} ,
423
426
range : [ 0 , 18 ]
424
427
}
425
428
] ,
426
429
sourceType : 'module' ,
427
430
comments : [ ] ,
428
431
loc : {
429
- start : { line : 1 , column : 0 } ,
430
- end : { line : 1 , column : 18 }
432
+ start : { line : 1 , column : 0 , offset : 0 } ,
433
+ end : { line : 1 , column : 18 , offset : 18 }
431
434
} ,
432
435
range : [ 0 , 18 ]
433
436
}
@@ -465,8 +468,8 @@ export let b = 'b'`,
465
468
end : 32 ,
466
469
name : 'b' ,
467
470
loc : {
468
- start : { line : 3 , column : 11 } ,
469
- end : { line : 3 , column : 12 }
471
+ start : { line : 3 , column : 11 , offset : 31 } ,
472
+ end : { line : 3 , column : 12 , offset : 32 }
470
473
} ,
471
474
range : [ 31 , 32 ]
472
475
} ,
@@ -477,39 +480,39 @@ export let b = 'b'`,
477
480
value : 'b' ,
478
481
raw : "'b'" ,
479
482
loc : {
480
- start : { line : 3 , column : 15 } ,
481
- end : { line : 3 , column : 18 }
483
+ start : { line : 3 , column : 15 , offset : 35 } ,
484
+ end : { line : 3 , column : 18 , offset : 38 }
482
485
} ,
483
486
range : [ 35 , 38 ]
484
487
} ,
485
488
loc : {
486
- start : { line : 3 , column : 11 } ,
487
- end : { line : 3 , column : 18 }
489
+ start : { line : 3 , column : 11 , offset : 31 } ,
490
+ end : { line : 3 , column : 18 , offset : 38 }
488
491
} ,
489
492
range : [ 31 , 38 ]
490
493
}
491
494
] ,
492
495
kind : 'let' ,
493
496
loc : {
494
- start : { line : 3 , column : 7 } ,
495
- end : { line : 3 , column : 18 }
497
+ start : { line : 3 , column : 7 , offset : 27 } ,
498
+ end : { line : 3 , column : 18 , offset : 38 }
496
499
} ,
497
500
range : [ 27 , 38 ]
498
501
} ,
499
502
specifiers : [ ] ,
500
503
source : null ,
501
504
loc : {
502
- start : { line : 3 , column : 0 } ,
503
- end : { line : 3 , column : 18 }
505
+ start : { line : 3 , column : 0 , offset : 20 } ,
506
+ end : { line : 3 , column : 18 , offset : 38 }
504
507
} ,
505
508
range : [ 20 , 38 ]
506
509
}
507
510
] ,
508
511
sourceType : 'module' ,
509
512
comments : [ ] ,
510
513
loc : {
511
- start : { line : 3 , column : 0 } ,
512
- end : { line : 3 , column : 18 }
514
+ start : { line : 3 , column : 0 , offset : 20 } ,
515
+ end : { line : 3 , column : 18 , offset : 38 }
513
516
} ,
514
517
range : [ 20 , 38 ]
515
518
}
0 commit comments