@@ -17,6 +17,14 @@ const setup = () => {
17
17
return { ...kit , transfer} ;
18
18
} ;
19
19
20
+ const assertMarkdownReExport = ( markdown : string ) => {
21
+ const kit = setup ( ) ;
22
+ kit . transfer . fromMarkdown ( 0 , markdown ) ;
23
+ kit . peritext . refresh ( ) ;
24
+ const back = kit . transfer . toMarkdown ( kit . peritext . rangeAll ( ) ! ) ;
25
+ expect ( back ) . toBe ( markdown ) ;
26
+ } ;
27
+
20
28
test ( 'ignores empty inline tags' , ( ) => {
21
29
const { peritext, transfer} = setup ( ) ;
22
30
const html =
@@ -218,7 +226,6 @@ describe('Markdown', () => {
218
226
const html = transfer . toHtml ( all ) ;
219
227
expect ( html ) . toBe ( '<blockquote><p>blockquote</p></blockquote>' ) ;
220
228
const md2 = transfer . toMarkdown ( all ) ;
221
- console . log ( md2 ) ;
222
229
expect ( md2 ) . toBe ( '> blockquote' ) ;
223
230
} ) ;
224
231
@@ -272,4 +279,66 @@ describe('Markdown', () => {
272
279
// console.log(md2);
273
280
expect ( md2 ) . toBe ( 'a' + md + 'b' ) ;
274
281
} ) ;
282
+
283
+ test ( 'can re-export a single paragraph' , ( ) => {
284
+ assertMarkdownReExport ( 'Hello world' ) ;
285
+ } ) ;
286
+
287
+ test ( 'can re-export a paragraph and a blockquote' , ( ) => {
288
+ assertMarkdownReExport ( 'Hello world\n\n> blockquote' ) ;
289
+ } ) ;
290
+
291
+ test ( 'can re-export a single blockquote' , ( ) => {
292
+ assertMarkdownReExport ( '> blockquote' ) ;
293
+ } ) ;
294
+
295
+ test ( 'can re-export a code block' , ( ) => {
296
+ assertMarkdownReExport ( '```\nconsole.log(123);\n```' ) ;
297
+ } ) ;
298
+
299
+ test . skip ( 'can re-export a code with language specified' , ( ) => {
300
+ assertMarkdownReExport ( '```js\nconsole.log(123);\n```' ) ;
301
+ } ) ;
302
+
303
+ test ( 'can re-export various block elements' , ( ) => {
304
+ assertMarkdownReExport ( 'paragraph\n\n> blockquote' ) ;
305
+ } ) ;
306
+
307
+ test ( 'can re-export various block elements' , ( ) => {
308
+ assertMarkdownReExport ( 'paragraph\n\n> blockquote' ) ;
309
+ assertMarkdownReExport ( 'paragraph\n\n> blockquot e\n\n```\ncode block\n```' ) ;
310
+ assertMarkdownReExport ( 'paragraph\n\n> blockquot e\n\n```\ncode block\n```\n\nparagraph 2' ) ;
311
+ assertMarkdownReExport ( 'paragraph\n\n> blockquot e\n\n```\ncode block\n```\n\nparagraph 2\n\n> blockquote 2' ) ;
312
+ } ) ;
313
+
314
+ test ( 'can re-export various block elements with inline formatting' , ( ) => {
315
+ assertMarkdownReExport ( 'par_a_g`a`ph\n\n> blo__c__kqu`o`te' ) ;
316
+ assertMarkdownReExport ( 'par_a_g`a`ph\n\n> blo__c__kqu`o`te e\n\n```\ncode block\n```' ) ;
317
+ assertMarkdownReExport ( 'par_a_g`a`ph\n\n> blo__c__kqu`o`te e\n\n```\ncode block\n```\n\npar_a_g`a`ph 2' ) ;
318
+ assertMarkdownReExport (
319
+ 'par_a_g`a`ph\n\n> blo__c__kqu`o`te e\n\n```\ncode block\n```\n\npar_a_g`a`ph 2\n\n> blo__c__kqu`o`te 2' ,
320
+ ) ;
321
+ } ) ;
322
+
323
+ test ( 'can re-export demo text' , ( ) => {
324
+ const markdown =
325
+ 'The German __automotive sector__ is in the process of _cutting ' +
326
+ 'thousands of jobs_ as it grapples with a global shift toward electric vehicles ' +
327
+ '— a transformation Musk himself has been at the forefront of.' +
328
+ '\n\n' +
329
+ '> To be, or not to be: that is the question.' +
330
+ '\n\n' +
331
+ 'This is code:' +
332
+ '\n\n' +
333
+ '```' +
334
+ '\n' +
335
+ 'console.log(123);' +
336
+ '\n' +
337
+ '```' +
338
+ '\n\n' +
339
+ 'A `ClipboardEvent` is dispatched for copy, cut, and paste events, and it contains ' +
340
+ 'a `clipboardData` property of type `DataTransfer`. The `DataTransfer` object ' +
341
+ 'is used by the Clipboard Events API to hold multiple representations of data.' ;
342
+ assertMarkdownReExport ( markdown ) ;
343
+ } ) ;
275
344
} ) ;
0 commit comments