1
- 'use strict'
1
+ import test from 'tape'
2
+ import unified from 'unified'
3
+ import parse from '../remark-parse/index.js'
4
+ import gfm from 'mdast-util-gfm/to-markdown.js'
5
+ import remarkStringify from './index.js'
2
6
3
- var test = require ( 'tape' )
4
- var unified = require ( 'unified' )
5
- var parse = require ( '../remark-parse/index.js' )
6
- var gfm = require ( 'mdast-util-gfm/to-markdown' )
7
-
8
- var stringify = require ( '.' )
9
-
10
- test ( 'remark().stringify(ast, file)' , function ( t ) {
7
+ test ( 'remarkStringify' , function ( t ) {
11
8
t . equal (
12
9
unified ( )
13
- . use ( stringify )
10
+ . use ( remarkStringify )
14
11
. stringify ( {
15
12
type : 'root' ,
16
13
children : [ { type : 'html' , value : '<!-- last line\n' } ]
@@ -22,15 +19,15 @@ test('remark().stringify(ast, file)', function (t) {
22
19
23
20
t . throws (
24
21
function ( ) {
25
- unified ( ) . use ( stringify ) . stringify ( false )
22
+ unified ( ) . use ( remarkStringify ) . stringify ( false )
26
23
} ,
27
24
/ f a l s e / ,
28
25
'should throw when `ast` is not an object'
29
26
)
30
27
31
28
t . throws (
32
29
function ( ) {
33
- unified ( ) . use ( stringify ) . stringify ( { type : 'unicorn' } )
30
+ unified ( ) . use ( remarkStringify ) . stringify ( { type : 'unicorn' } )
34
31
} ,
35
32
/ u n i c o r n / ,
36
33
'should throw when `ast` is not a valid node'
@@ -39,7 +36,7 @@ test('remark().stringify(ast, file)', function (t) {
39
36
t . throws (
40
37
function ( ) {
41
38
unified ( )
42
- . use ( stringify )
39
+ . use ( remarkStringify )
43
40
. data ( 'settings' , { bullet : true } )
44
41
. stringify ( { type : 'listItem' } )
45
42
} ,
@@ -50,7 +47,7 @@ test('remark().stringify(ast, file)', function (t) {
50
47
t . throws (
51
48
function ( ) {
52
49
unified ( )
53
- . use ( stringify )
50
+ . use ( remarkStringify )
54
51
. data ( 'settings' , { listItemIndent : 'foo' } )
55
52
. stringify ( { type : 'listItem' } )
56
53
} ,
@@ -61,7 +58,7 @@ test('remark().stringify(ast, file)', function (t) {
61
58
t . throws (
62
59
function ( ) {
63
60
unified ( )
64
- . use ( stringify )
61
+ . use ( remarkStringify )
65
62
. data ( 'settings' , { rule : true } )
66
63
. stringify ( { type : 'thematicBreak' } )
67
64
} ,
@@ -72,7 +69,7 @@ test('remark().stringify(ast, file)', function (t) {
72
69
t . throws (
73
70
function ( ) {
74
71
unified ( )
75
- . use ( stringify )
72
+ . use ( remarkStringify )
76
73
. data ( 'settings' , { ruleRepetition : 1 } )
77
74
. stringify ( { type : 'thematicBreak' } )
78
75
} ,
@@ -83,7 +80,7 @@ test('remark().stringify(ast, file)', function (t) {
83
80
t . throws (
84
81
function ( ) {
85
82
unified ( )
86
- . use ( stringify )
83
+ . use ( remarkStringify )
87
84
. data ( 'settings' , { ruleRepetition : true } )
88
85
. stringify ( { type : 'thematicBreak' } )
89
86
} ,
@@ -94,7 +91,7 @@ test('remark().stringify(ast, file)', function (t) {
94
91
t . throws (
95
92
function ( ) {
96
93
unified ( )
97
- . use ( stringify )
94
+ . use ( remarkStringify )
98
95
. data ( 'settings' , { emphasis : '-' } )
99
96
. stringify ( { type : 'emphasis' } )
100
97
} ,
@@ -105,7 +102,7 @@ test('remark().stringify(ast, file)', function (t) {
105
102
t . throws (
106
103
function ( ) {
107
104
unified ( )
108
- . use ( stringify )
105
+ . use ( remarkStringify )
109
106
. data ( 'settings' , { strong : '-' } )
110
107
. stringify ( { type : 'strong' } )
111
108
} ,
@@ -116,7 +113,7 @@ test('remark().stringify(ast, file)', function (t) {
116
113
t . throws (
117
114
function ( ) {
118
115
unified ( )
119
- . use ( stringify )
116
+ . use ( remarkStringify )
120
117
. data ( 'settings' , { fence : '-' } )
121
118
. stringify ( { type : 'code' } )
122
119
} ,
@@ -253,7 +250,7 @@ test('remark().stringify(ast, file)', function (t) {
253
250
st . end ( )
254
251
255
252
function toString ( value ) {
256
- return String ( unified ( ) . use ( stringify ) . stringify ( value ) )
253
+ return String ( unified ( ) . use ( remarkStringify ) . stringify ( value ) )
257
254
}
258
255
} )
259
256
@@ -269,27 +266,27 @@ test('remark().stringify(ast, file)', function (t) {
269
266
]
270
267
271
268
st . equal (
272
- toString ( { type : 'listItem' , children : children } ) ,
269
+ toString ( { type : 'listItem' , children} ) ,
273
270
'* alpha\n\n > bravo\n' ,
274
271
'no spread'
275
272
)
276
273
277
274
st . equal (
278
- toString ( { type : 'listItem' , spread : true , children : children } ) ,
275
+ toString ( { type : 'listItem' , spread : true , children} ) ,
279
276
'* alpha\n\n > bravo\n' ,
280
277
'spread: true'
281
278
)
282
279
283
280
st . equal (
284
- toString ( { type : 'listItem' , spread : false , children : children } ) ,
281
+ toString ( { type : 'listItem' , spread : false , children} ) ,
285
282
'* alpha\n > bravo\n' ,
286
283
'spread: false'
287
284
)
288
285
289
286
st . end ( )
290
287
291
288
function toString ( value ) {
292
- return String ( unified ( ) . use ( stringify ) . stringify ( value ) )
289
+ return String ( unified ( ) . use ( remarkStringify ) . stringify ( value ) )
293
290
}
294
291
} )
295
292
@@ -299,7 +296,7 @@ test('remark().stringify(ast, file)', function (t) {
299
296
st . end ( )
300
297
301
298
function toString ( value ) {
302
- return String ( unified ( ) . use ( stringify ) . stringify ( value ) )
299
+ return String ( unified ( ) . use ( remarkStringify ) . stringify ( value ) )
303
300
}
304
301
} )
305
302
@@ -318,7 +315,7 @@ test('remark().stringify(ast, file)', function (t) {
318
315
st . equal (
319
316
unified ( )
320
317
. use ( parse )
321
- . use ( stringify )
318
+ . use ( remarkStringify )
322
319
. processSync ( test [ 1 ] + '\n\n[bravo]: #\n' )
323
320
. toString ( ) ,
324
321
test [ 1 ] + '\n\n[bravo]: #\n' ,
@@ -355,7 +352,7 @@ test('remark().stringify(ast, file)', function (t) {
355
352
st . end ( )
356
353
357
354
function toString ( value ) {
358
- return String ( unified ( ) . use ( stringify ) . stringify ( value ) )
355
+ return String ( unified ( ) . use ( remarkStringify ) . stringify ( value ) )
359
356
}
360
357
} )
361
358
@@ -364,21 +361,21 @@ test('remark().stringify(ast, file)', function (t) {
364
361
365
362
var example = '[example@foo.com](mailto:example@foo.com)'
366
363
st . equal (
367
- unified ( ) . use ( parse ) . use ( stringify ) . processSync ( example ) . toString ( ) ,
364
+ unified ( ) . use ( parse ) . use ( remarkStringify ) . processSync ( example ) . toString ( ) ,
368
365
'<example@foo.com>\n' ,
369
366
'url is `mailto:` plus link text'
370
367
)
371
368
372
369
example = '[mailto:example@foo.com](mailto:example@foo.com)'
373
370
st . equal (
374
- unified ( ) . use ( parse ) . use ( stringify ) . processSync ( example ) . toString ( ) ,
371
+ unified ( ) . use ( parse ) . use ( remarkStringify ) . processSync ( example ) . toString ( ) ,
375
372
'<mailto:example@foo.com>\n' ,
376
373
'url is link text'
377
374
)
378
375
379
376
example = '[example](mailto:example@foo.com)\n'
380
377
st . equal (
381
- unified ( ) . use ( parse ) . use ( stringify ) . processSync ( example ) . toString ( ) ,
378
+ unified ( ) . use ( parse ) . use ( remarkStringify ) . processSync ( example ) . toString ( ) ,
382
379
example ,
383
380
'url is not link text'
384
381
)
@@ -460,7 +457,7 @@ test('stringify escapes', function (t) {
460
457
test ( 'extensions' , function ( t ) {
461
458
var doc = unified ( )
462
459
. data ( 'toMarkdownExtensions' , [ gfm ( ) ] )
463
- . use ( stringify )
460
+ . use ( remarkStringify )
464
461
. stringify ( {
465
462
type : 'root' ,
466
463
children : [
@@ -596,8 +593,8 @@ test('extensions', function (t) {
596
593
function toString ( value , options ) {
597
594
var tree =
598
595
typeof value === 'string'
599
- ? { type : 'paragraph' , children : [ { type : 'text' , value : value } ] }
596
+ ? { type : 'paragraph' , children : [ { type : 'text' , value} ] }
600
597
: value
601
598
602
- return unified ( ) . use ( stringify , options ) . stringify ( tree )
599
+ return unified ( ) . use ( remarkStringify , options ) . stringify ( tree )
603
600
}
0 commit comments