@podlite/markdown 0.0.30 → 0.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/t/parse.test.ts DELETED
@@ -1,1833 +0,0 @@
1
- import { frozenIds, isValidateError, podlitePluggable } from '@podlite/schema'
2
- import { validateAstTree } from '@podlite/schema'
3
- import { md2ast } from '../src/tools'
4
- import { PodliteDocument } from '@podlite/schema'
5
-
6
- const process = src => {
7
- return frozenIds()(md2ast(src))
8
- }
9
-
10
- export const parse = (str: string): PodliteDocument => {
11
- let podlite = podlitePluggable().use({})
12
- let tree = podlite.parse(str)
13
- const asAst = podlite.toAstResult(tree)
14
- return asAst.interator
15
- }
16
- it('=markdown: parse para', () => {
17
- const pod = `text`
18
- // const tree1 = parse(pod);
19
- const tree = process(pod)
20
- const r = validateAstTree([tree])
21
- expect(r).toEqual([])
22
- const errorDescribe = isValidateError(r, tree)
23
- expect(process(pod)).toMatchInlineSnapshot(`
24
- Object {
25
- "content": Array [
26
- Object {
27
- "content": Array [
28
- "text",
29
- ],
30
- "id": "id",
31
- "location": Object {
32
- "end": Object {
33
- "column": 5,
34
- "line": 1,
35
- "offset": 4,
36
- },
37
- "start": Object {
38
- "column": 1,
39
- "line": 1,
40
- "offset": 0,
41
- },
42
- },
43
- "margin": "",
44
- "text": "text",
45
- "type": "para",
46
- },
47
- ],
48
- "id": "id",
49
- "margin": "",
50
- "name": "root",
51
- "type": "block",
52
- }
53
- `)
54
- })
55
-
56
- it.skip('[markdown]: parse para', () => {
57
- const pod = `text`
58
- const tree = process(pod)
59
- const r = validateAstTree([tree])
60
- expect(r).toEqual([])
61
- const errorDescribe = isValidateError(r, tree)
62
- // expect(process(pod)).toMatchInlineSnapshot();
63
- })
64
-
65
- it('[markdown]: parse headers', () => {
66
- const pod = `## build
67
-
68
- Generate JavaScript documentation as a list of parsed JSDoc
69
- comments, given a root file as a path`
70
- const tree = process(pod)
71
- const r = validateAstTree([tree])
72
- expect(r).toEqual([])
73
- const errorDescribe = isValidateError(r, tree)
74
- expect(process(pod)).toMatchInlineSnapshot(`
75
- Object {
76
- "content": Array [
77
- Object {
78
- "content": Array [
79
- "build",
80
- ],
81
- "id": "id",
82
- "level": 2,
83
- "location": Object {
84
- "end": Object {
85
- "column": 9,
86
- "line": 1,
87
- "offset": 8,
88
- },
89
- "start": Object {
90
- "column": 1,
91
- "line": 1,
92
- "offset": 0,
93
- },
94
- },
95
- "margin": "",
96
- "name": "head",
97
- "type": "block",
98
- },
99
- Object {
100
- "content": Array [
101
- "Generate JavaScript documentation as a list of parsed JSDoc
102
- comments, given a root file as a path",
103
- ],
104
- "id": "id",
105
- "location": Object {
106
- "end": Object {
107
- "column": 38,
108
- "line": 4,
109
- "offset": 107,
110
- },
111
- "start": Object {
112
- "column": 1,
113
- "line": 3,
114
- "offset": 10,
115
- },
116
- },
117
- "margin": "",
118
- "text": "text",
119
- "type": "para",
120
- },
121
- ],
122
- "id": "id",
123
- "margin": "",
124
- "name": "root",
125
- "type": "block",
126
- }
127
- `)
128
- })
129
- it('[markdown]: parse link', () => {
130
- const pod = `[#raku IRC channel](https://raku.org/community/irc)`
131
- const tree = process(pod)
132
- const r = validateAstTree([tree])
133
- expect(r).toEqual([])
134
- const errorDescribe = isValidateError(r, tree)
135
- expect(process(pod)).toMatchInlineSnapshot(`
136
- Object {
137
- "content": Array [
138
- Object {
139
- "content": Array [
140
- Object {
141
- "content": Array [
142
- "#raku IRC channel",
143
- ],
144
- "meta": "https://raku.org/community/irc",
145
- "name": "L",
146
- "type": "fcode",
147
- },
148
- ],
149
- "id": "id",
150
- "location": Object {
151
- "end": Object {
152
- "column": 52,
153
- "line": 1,
154
- "offset": 51,
155
- },
156
- "start": Object {
157
- "column": 1,
158
- "line": 1,
159
- "offset": 0,
160
- },
161
- },
162
- "margin": "",
163
- "text": "text",
164
- "type": "para",
165
- },
166
- ],
167
- "id": "id",
168
- "margin": "",
169
- "name": "root",
170
- "type": "block",
171
- }
172
- `)
173
- })
174
- it('[markdown]: parse image', () => {
175
- const pod = `![foo](/url "title")`
176
- const tree = process(pod)
177
- const r = validateAstTree([tree])
178
- expect(r).toEqual([])
179
- const errorDescribe = isValidateError(r, tree)
180
- expect(process(pod)).toMatchInlineSnapshot(`
181
- Object {
182
- "content": Array [
183
- Object {
184
- "content": Array [
185
- Object {
186
- "config": Array [],
187
- "content": Array [
188
- Object {
189
- "alt": "foo",
190
- "src": "/url",
191
- "type": "image",
192
- },
193
- Object {
194
- "content": Array [
195
- "title",
196
- ],
197
- "name": "caption",
198
- "type": "block",
199
- },
200
- ],
201
- "id": "id",
202
- "location": Object {
203
- "end": Object {
204
- "column": 21,
205
- "line": 1,
206
- "offset": 20,
207
- },
208
- "start": Object {
209
- "column": 1,
210
- "line": 1,
211
- "offset": 0,
212
- },
213
- },
214
- "margin": "",
215
- "name": "Image",
216
- "type": "block",
217
- },
218
- ],
219
- "id": "id",
220
- "location": Object {
221
- "end": Object {
222
- "column": 21,
223
- "line": 1,
224
- "offset": 20,
225
- },
226
- "start": Object {
227
- "column": 1,
228
- "line": 1,
229
- "offset": 0,
230
- },
231
- },
232
- "margin": "",
233
- "text": "text",
234
- "type": "para",
235
- },
236
- ],
237
- "id": "id",
238
- "margin": "",
239
- "name": "root",
240
- "type": "block",
241
- }
242
- `)
243
- })
244
-
245
- it('[markdown]: parse refs', () => {
246
- const pod = `### Table of Contents
247
-
248
- - [lint][1]
249
- - [Parameters][2]
250
-
251
-
252
- [1]: #lint
253
-
254
- [2]: #parameters`
255
- const tree = process(pod)
256
- const r = validateAstTree([tree])
257
- expect(r).toEqual([])
258
- const errorDescribe = isValidateError(r, tree)
259
- expect(process(pod)).toMatchInlineSnapshot(`
260
- Object {
261
- "content": Array [
262
- Object {
263
- "content": Array [
264
- "Table of Contents",
265
- ],
266
- "id": "id",
267
- "level": 3,
268
- "location": Object {
269
- "end": Object {
270
- "column": 22,
271
- "line": 1,
272
- "offset": 21,
273
- },
274
- "start": Object {
275
- "column": 1,
276
- "line": 1,
277
- "offset": 0,
278
- },
279
- },
280
- "margin": "",
281
- "name": "head",
282
- "type": "block",
283
- },
284
- Object {
285
- "content": Array [
286
- Object {
287
- "content": Array [
288
- Object {
289
- "content": Array [
290
- Object {
291
- "content": Array [
292
- "lint",
293
- ],
294
- "meta": "#lint",
295
- "name": "L",
296
- "type": "fcode",
297
- },
298
- ],
299
- "id": "id",
300
- "location": Object {
301
- "end": Object {
302
- "column": 14,
303
- "line": 3,
304
- "offset": 36,
305
- },
306
- "start": Object {
307
- "column": 5,
308
- "line": 3,
309
- "offset": 27,
310
- },
311
- },
312
- "margin": "",
313
- "text": "text",
314
- "type": "para",
315
- },
316
- Object {
317
- "content": Array [
318
- Object {
319
- "content": Array [
320
- Object {
321
- "content": Array [
322
- Object {
323
- "content": Array [
324
- "Parameters",
325
- ],
326
- "meta": "#parameters",
327
- "name": "L",
328
- "type": "fcode",
329
- },
330
- ],
331
- "id": "id",
332
- "location": Object {
333
- "end": Object {
334
- "column": 24,
335
- "line": 4,
336
- "offset": 60,
337
- },
338
- "start": Object {
339
- "column": 9,
340
- "line": 4,
341
- "offset": 45,
342
- },
343
- },
344
- "margin": "",
345
- "text": "text",
346
- "type": "para",
347
- },
348
- ],
349
- "id": "id",
350
- "level": 2,
351
- "location": Object {
352
- "end": Object {
353
- "column": 24,
354
- "line": 4,
355
- "offset": 60,
356
- },
357
- "start": Object {
358
- "column": 5,
359
- "line": 4,
360
- "offset": 41,
361
- },
362
- },
363
- "margin": "",
364
- "name": "item",
365
- "type": "block",
366
- },
367
- ],
368
- "id": "id",
369
- "level": 2,
370
- "list": "itemized",
371
- "margin": "",
372
- "type": "list",
373
- },
374
- ],
375
- "id": "id",
376
- "level": 1,
377
- "location": Object {
378
- "end": Object {
379
- "column": 24,
380
- "line": 4,
381
- "offset": 60,
382
- },
383
- "start": Object {
384
- "column": 1,
385
- "line": 3,
386
- "offset": 23,
387
- },
388
- },
389
- "margin": "",
390
- "name": "item",
391
- "type": "block",
392
- },
393
- ],
394
- "id": "id",
395
- "level": 1,
396
- "list": "itemized",
397
- "margin": "",
398
- "type": "list",
399
- },
400
- ],
401
- "id": "id",
402
- "margin": "",
403
- "name": "root",
404
- "type": "block",
405
- }
406
- `)
407
- })
408
-
409
- it('[markdown]: broken_refs', () => {
410
- const pod = `### Parameters
411
-
412
- - \`comments\` **[Array][17]<[Object][19]>** parsed comments
413
- - \`args\` **[Object][19]** Options that can customize the output
414
- `
415
- const tree = process(pod)
416
- const r = validateAstTree([tree])
417
- expect(r).toEqual([])
418
- const errorDescribe = isValidateError(r, tree)
419
- expect(process(pod)).toMatchInlineSnapshot(`
420
- Object {
421
- "content": Array [
422
- Object {
423
- "content": Array [
424
- "Parameters",
425
- ],
426
- "id": "id",
427
- "level": 3,
428
- "location": Object {
429
- "end": Object {
430
- "column": 15,
431
- "line": 1,
432
- "offset": 14,
433
- },
434
- "start": Object {
435
- "column": 1,
436
- "line": 1,
437
- "offset": 0,
438
- },
439
- },
440
- "margin": "",
441
- "name": "head",
442
- "type": "block",
443
- },
444
- Object {
445
- "content": Array [
446
- Object {
447
- "content": Array [
448
- Object {
449
- "content": Array [
450
- Object {
451
- "content": Array [
452
- "comments",
453
- ],
454
- "name": "C",
455
- "type": "fcode",
456
- },
457
- " ",
458
- Object {
459
- "content": Array [
460
- "[Array][17]<[Object][19]>",
461
- ],
462
- "name": "B",
463
- "type": "fcode",
464
- },
465
- " parsed comments",
466
- ],
467
- "id": "id",
468
- "location": Object {
469
- "end": Object {
470
- "column": 64,
471
- "line": 3,
472
- "offset": 79,
473
- },
474
- "start": Object {
475
- "column": 5,
476
- "line": 3,
477
- "offset": 20,
478
- },
479
- },
480
- "margin": "",
481
- "text": "text",
482
- "type": "para",
483
- },
484
- ],
485
- "id": "id",
486
- "level": 1,
487
- "location": Object {
488
- "end": Object {
489
- "column": 64,
490
- "line": 3,
491
- "offset": 79,
492
- },
493
- "start": Object {
494
- "column": 1,
495
- "line": 3,
496
- "offset": 16,
497
- },
498
- },
499
- "margin": "",
500
- "name": "item",
501
- "type": "block",
502
- },
503
- Object {
504
- "content": Array [
505
- Object {
506
- "content": Array [
507
- Object {
508
- "content": Array [
509
- "args",
510
- ],
511
- "name": "C",
512
- "type": "fcode",
513
- },
514
- " ",
515
- Object {
516
- "content": Array [
517
- "[Object][19]",
518
- ],
519
- "name": "B",
520
- "type": "fcode",
521
- },
522
- " Options that can customize the output",
523
- ],
524
- "id": "id",
525
- "location": Object {
526
- "end": Object {
527
- "column": 66,
528
- "line": 4,
529
- "offset": 145,
530
- },
531
- "start": Object {
532
- "column": 5,
533
- "line": 4,
534
- "offset": 84,
535
- },
536
- },
537
- "margin": "",
538
- "text": "text",
539
- "type": "para",
540
- },
541
- ],
542
- "id": "id",
543
- "level": 1,
544
- "location": Object {
545
- "end": Object {
546
- "column": 66,
547
- "line": 4,
548
- "offset": 145,
549
- },
550
- "start": Object {
551
- "column": 1,
552
- "line": 4,
553
- "offset": 80,
554
- },
555
- },
556
- "margin": "",
557
- "name": "item",
558
- "type": "block",
559
- },
560
- ],
561
- "id": "id",
562
- "level": 1,
563
- "list": "itemized",
564
- "margin": "",
565
- "type": "list",
566
- },
567
- ],
568
- "id": "id",
569
- "margin": "",
570
- "name": "root",
571
- "type": "block",
572
- }
573
- `)
574
- })
575
-
576
- it('[markdown]: parse code', () => {
577
- const pod = `
578
- \`\`\`javascript
579
- var documentation = require('documentation');
580
- \`\`\`
581
- `
582
- const tree = process(pod)
583
- const r = validateAstTree([tree])
584
- expect(r).toEqual([])
585
- const errorDescribe = isValidateError(r, tree)
586
- expect(process(pod)).toMatchInlineSnapshot(`
587
- Object {
588
- "content": Array [
589
- Object {
590
- "config": Array [
591
- Object {
592
- "name": "lang",
593
- "type": "string",
594
- "value": "javascript",
595
- },
596
- ],
597
- "content": Array [
598
- Object {
599
- "type": "verbatim",
600
- "value": "var documentation = require('documentation');",
601
- },
602
- ],
603
- "id": "id",
604
- "location": Object {
605
- "end": Object {
606
- "column": 4,
607
- "line": 4,
608
- "offset": 64,
609
- },
610
- "start": Object {
611
- "column": 1,
612
- "line": 2,
613
- "offset": 1,
614
- },
615
- },
616
- "margin": "",
617
- "name": "code",
618
- "type": "block",
619
- },
620
- ],
621
- "id": "id",
622
- "margin": "",
623
- "name": "root",
624
- "type": "block",
625
- }
626
- `)
627
- })
628
-
629
- it('[markdown]: inline_code', () => {
630
- const pod = `
631
- *This text will be italic*
632
- _This will also be italic_
633
-
634
- **This text will be bold**
635
- __This will also be bold__
636
-
637
- _You **can** combine them_
638
- `
639
- const tree = process(pod)
640
- const r = validateAstTree([tree])
641
- expect(r).toEqual([])
642
- const errorDescribe = isValidateError(r, tree)
643
- expect(process(pod)).toMatchInlineSnapshot(`
644
- Object {
645
- "content": Array [
646
- Object {
647
- "content": Array [
648
- Object {
649
- "content": Array [
650
- "This text will be italic",
651
- ],
652
- "name": "I",
653
- "type": "fcode",
654
- },
655
- "
656
- ",
657
- Object {
658
- "content": Array [
659
- "This will also be italic",
660
- ],
661
- "name": "I",
662
- "type": "fcode",
663
- },
664
- ],
665
- "id": "id",
666
- "location": Object {
667
- "end": Object {
668
- "column": 27,
669
- "line": 3,
670
- "offset": 54,
671
- },
672
- "start": Object {
673
- "column": 1,
674
- "line": 2,
675
- "offset": 1,
676
- },
677
- },
678
- "margin": "",
679
- "text": "text",
680
- "type": "para",
681
- },
682
- Object {
683
- "content": Array [
684
- Object {
685
- "content": Array [
686
- "This text will be bold",
687
- ],
688
- "name": "B",
689
- "type": "fcode",
690
- },
691
- "
692
- ",
693
- Object {
694
- "content": Array [
695
- "This will also be bold",
696
- ],
697
- "name": "B",
698
- "type": "fcode",
699
- },
700
- ],
701
- "id": "id",
702
- "location": Object {
703
- "end": Object {
704
- "column": 27,
705
- "line": 6,
706
- "offset": 109,
707
- },
708
- "start": Object {
709
- "column": 1,
710
- "line": 5,
711
- "offset": 56,
712
- },
713
- },
714
- "margin": "",
715
- "text": "text",
716
- "type": "para",
717
- },
718
- Object {
719
- "content": Array [
720
- Object {
721
- "content": Array [
722
- "You ",
723
- Object {
724
- "content": Array [
725
- "can",
726
- ],
727
- "name": "B",
728
- "type": "fcode",
729
- },
730
- " combine them",
731
- ],
732
- "name": "I",
733
- "type": "fcode",
734
- },
735
- ],
736
- "id": "id",
737
- "location": Object {
738
- "end": Object {
739
- "column": 27,
740
- "line": 8,
741
- "offset": 137,
742
- },
743
- "start": Object {
744
- "column": 1,
745
- "line": 8,
746
- "offset": 111,
747
- },
748
- },
749
- "margin": "",
750
- "text": "text",
751
- "type": "para",
752
- },
753
- ],
754
- "id": "id",
755
- "margin": "",
756
- "name": "root",
757
- "type": "block",
758
- }
759
- `)
760
- })
761
-
762
- it('[markdown]: thematic_break', () => {
763
- const pod = `
764
-
765
- ---
766
- `
767
- const tree = process(pod)
768
- const r = validateAstTree([tree])
769
- expect(r).toEqual([])
770
- const errorDescribe = isValidateError(r, tree)
771
- expect(process(pod)).toMatchInlineSnapshot(`
772
- Object {
773
- "content": Array [],
774
- "id": "id",
775
- "margin": "",
776
- "name": "root",
777
- "type": "block",
778
- }
779
- `)
780
- })
781
-
782
- it('[markdown]: blockquote', () => {
783
- const pod = `
784
- As Kanye West said:
785
-
786
- > We're living the future so
787
- > the present is our past.
788
- `
789
- const tree = process(pod)
790
- const r = validateAstTree([tree])
791
- expect(r).toEqual([])
792
- const errorDescribe = isValidateError(r, tree)
793
- expect(process(pod)).toMatchInlineSnapshot(`
794
- Object {
795
- "content": Array [
796
- Object {
797
- "content": Array [
798
- "As Kanye West said:",
799
- ],
800
- "id": "id",
801
- "location": Object {
802
- "end": Object {
803
- "column": 20,
804
- "line": 2,
805
- "offset": 20,
806
- },
807
- "start": Object {
808
- "column": 1,
809
- "line": 2,
810
- "offset": 1,
811
- },
812
- },
813
- "margin": "",
814
- "text": "text",
815
- "type": "para",
816
- },
817
- Object {
818
- "content": Array [
819
- Object {
820
- "content": Array [
821
- "We're living the future so
822
- the present is our past.",
823
- ],
824
- "id": "id",
825
- "location": Object {
826
- "end": Object {
827
- "column": 27,
828
- "line": 5,
829
- "offset": 77,
830
- },
831
- "start": Object {
832
- "column": 3,
833
- "line": 4,
834
- "offset": 24,
835
- },
836
- },
837
- "margin": "",
838
- "text": "text",
839
- "type": "para",
840
- },
841
- ],
842
- "id": "id",
843
- "location": Object {
844
- "end": Object {
845
- "column": 27,
846
- "line": 5,
847
- "offset": 77,
848
- },
849
- "start": Object {
850
- "column": 1,
851
- "line": 4,
852
- "offset": 22,
853
- },
854
- },
855
- "margin": "",
856
- "name": "nested",
857
- "type": "block",
858
- },
859
- ],
860
- "id": "id",
861
- "margin": "",
862
- "name": "root",
863
- "type": "block",
864
- }
865
- `)
866
- })
867
-
868
- it('[markdown]: parse table', () => {
869
- const pod = `
870
- First Header | Second Header
871
- ------------ | -------------
872
- Content from cell 1 | Content from cell 2
873
- Content in the first column | Content in the second column
874
- `
875
- const tree = process(pod)
876
- const r = validateAstTree([tree])
877
- expect(r).toEqual([])
878
- const errorDescribe = isValidateError(r, tree)
879
- expect(process(pod)).toMatchInlineSnapshot(`
880
- Object {
881
- "content": Array [
882
- Object {
883
- "align": Array [
884
- null,
885
- null,
886
- ],
887
- "content": Array [
888
- Object {
889
- "content": Array [
890
- Object {
891
- "content": Array [
892
- "First Header",
893
- ],
894
- "id": "id",
895
- "location": Object {
896
- "end": Object {
897
- "column": 15,
898
- "line": 2,
899
- "offset": 15,
900
- },
901
- "start": Object {
902
- "column": 1,
903
- "line": 2,
904
- "offset": 1,
905
- },
906
- },
907
- "margin": "",
908
- "name": "table_cell",
909
- "type": "block",
910
- },
911
- Object {
912
- "content": Array [
913
- "Second Header",
914
- ],
915
- "id": "id",
916
- "location": Object {
917
- "end": Object {
918
- "column": 29,
919
- "line": 2,
920
- "offset": 29,
921
- },
922
- "start": Object {
923
- "column": 15,
924
- "line": 2,
925
- "offset": 15,
926
- },
927
- },
928
- "margin": "",
929
- "name": "table_cell",
930
- "type": "block",
931
- },
932
- ],
933
- "id": "id",
934
- "location": Object {
935
- "end": Object {
936
- "column": 29,
937
- "line": 2,
938
- "offset": 29,
939
- },
940
- "start": Object {
941
- "column": 1,
942
- "line": 2,
943
- "offset": 1,
944
- },
945
- },
946
- "margin": "",
947
- "name": "table_head",
948
- "type": "block",
949
- },
950
- Object {
951
- "content": Array [
952
- Object {
953
- "content": Array [
954
- "Content from cell 1",
955
- ],
956
- "id": "id",
957
- "location": Object {
958
- "end": Object {
959
- "column": 22,
960
- "line": 4,
961
- "offset": 80,
962
- },
963
- "start": Object {
964
- "column": 1,
965
- "line": 4,
966
- "offset": 59,
967
- },
968
- },
969
- "margin": "",
970
- "name": "table_cell",
971
- "type": "block",
972
- },
973
- Object {
974
- "content": Array [
975
- "Content from cell 2",
976
- ],
977
- "id": "id",
978
- "location": Object {
979
- "end": Object {
980
- "column": 42,
981
- "line": 4,
982
- "offset": 100,
983
- },
984
- "start": Object {
985
- "column": 22,
986
- "line": 4,
987
- "offset": 80,
988
- },
989
- },
990
- "margin": "",
991
- "name": "table_cell",
992
- "type": "block",
993
- },
994
- ],
995
- "id": "id",
996
- "location": Object {
997
- "end": Object {
998
- "column": 42,
999
- "line": 4,
1000
- "offset": 100,
1001
- },
1002
- "start": Object {
1003
- "column": 1,
1004
- "line": 4,
1005
- "offset": 59,
1006
- },
1007
- },
1008
- "margin": "",
1009
- "name": "table_row",
1010
- "type": "block",
1011
- },
1012
- Object {
1013
- "content": Array [
1014
- Object {
1015
- "content": Array [
1016
- "Content in the first column",
1017
- ],
1018
- "id": "id",
1019
- "location": Object {
1020
- "end": Object {
1021
- "column": 30,
1022
- "line": 5,
1023
- "offset": 130,
1024
- },
1025
- "start": Object {
1026
- "column": 1,
1027
- "line": 5,
1028
- "offset": 101,
1029
- },
1030
- },
1031
- "margin": "",
1032
- "name": "table_cell",
1033
- "type": "block",
1034
- },
1035
- Object {
1036
- "content": Array [
1037
- "Content in the second column",
1038
- ],
1039
- "id": "id",
1040
- "location": Object {
1041
- "end": Object {
1042
- "column": 59,
1043
- "line": 5,
1044
- "offset": 159,
1045
- },
1046
- "start": Object {
1047
- "column": 30,
1048
- "line": 5,
1049
- "offset": 130,
1050
- },
1051
- },
1052
- "margin": "",
1053
- "name": "table_cell",
1054
- "type": "block",
1055
- },
1056
- ],
1057
- "id": "id",
1058
- "location": Object {
1059
- "end": Object {
1060
- "column": 59,
1061
- "line": 5,
1062
- "offset": 159,
1063
- },
1064
- "start": Object {
1065
- "column": 1,
1066
- "line": 5,
1067
- "offset": 101,
1068
- },
1069
- },
1070
- "margin": "",
1071
- "name": "table_row",
1072
- "type": "block",
1073
- },
1074
- ],
1075
- "id": "id",
1076
- "location": Object {
1077
- "end": Object {
1078
- "column": 59,
1079
- "line": 5,
1080
- "offset": 159,
1081
- },
1082
- "start": Object {
1083
- "column": 1,
1084
- "line": 2,
1085
- "offset": 1,
1086
- },
1087
- },
1088
- "margin": "",
1089
- "name": "table",
1090
- "type": "block",
1091
- },
1092
- ],
1093
- "id": "id",
1094
- "margin": "",
1095
- "name": "root",
1096
- "type": "block",
1097
- }
1098
- `)
1099
- })
1100
-
1101
- it('[markdown]: parse table with empty header', () => {
1102
- const pod = `
1103
- | | |
1104
- ------------ | -------------
1105
- Content from cell 1 | Content from cell 2
1106
- Content in the first column | Content in the second column
1107
- `
1108
- const tree = process(pod)
1109
- const r = validateAstTree([tree])
1110
- expect(r).toEqual([])
1111
- const errorDescribe = isValidateError(r, tree)
1112
- expect(process(pod)).toMatchInlineSnapshot(`
1113
- Object {
1114
- "content": Array [
1115
- Object {
1116
- "align": Array [
1117
- null,
1118
- null,
1119
- ],
1120
- "content": Array [
1121
- Object {
1122
- "content": Array [
1123
- Object {
1124
- "content": Array [],
1125
- "id": "id",
1126
- "location": Object {
1127
- "end": Object {
1128
- "column": 6,
1129
- "line": 2,
1130
- "offset": 6,
1131
- },
1132
- "start": Object {
1133
- "column": 3,
1134
- "line": 2,
1135
- "offset": 3,
1136
- },
1137
- },
1138
- "margin": "",
1139
- "name": "table_cell",
1140
- "type": "block",
1141
- },
1142
- Object {
1143
- "content": Array [],
1144
- "id": "id",
1145
- "location": Object {
1146
- "end": Object {
1147
- "column": 8,
1148
- "line": 2,
1149
- "offset": 8,
1150
- },
1151
- "start": Object {
1152
- "column": 6,
1153
- "line": 2,
1154
- "offset": 6,
1155
- },
1156
- },
1157
- "margin": "",
1158
- "name": "table_cell",
1159
- "type": "block",
1160
- },
1161
- ],
1162
- "id": "id",
1163
- "location": Object {
1164
- "end": Object {
1165
- "column": 8,
1166
- "line": 2,
1167
- "offset": 8,
1168
- },
1169
- "start": Object {
1170
- "column": 3,
1171
- "line": 2,
1172
- "offset": 3,
1173
- },
1174
- },
1175
- "margin": "",
1176
- "name": "table_head",
1177
- "type": "block",
1178
- },
1179
- Object {
1180
- "content": Array [
1181
- Object {
1182
- "content": Array [
1183
- "Content from cell 1",
1184
- ],
1185
- "id": "id",
1186
- "location": Object {
1187
- "end": Object {
1188
- "column": 24,
1189
- "line": 4,
1190
- "offset": 63,
1191
- },
1192
- "start": Object {
1193
- "column": 3,
1194
- "line": 4,
1195
- "offset": 42,
1196
- },
1197
- },
1198
- "margin": "",
1199
- "name": "table_cell",
1200
- "type": "block",
1201
- },
1202
- Object {
1203
- "content": Array [
1204
- "Content from cell 2",
1205
- ],
1206
- "id": "id",
1207
- "location": Object {
1208
- "end": Object {
1209
- "column": 44,
1210
- "line": 4,
1211
- "offset": 83,
1212
- },
1213
- "start": Object {
1214
- "column": 24,
1215
- "line": 4,
1216
- "offset": 63,
1217
- },
1218
- },
1219
- "margin": "",
1220
- "name": "table_cell",
1221
- "type": "block",
1222
- },
1223
- ],
1224
- "id": "id",
1225
- "location": Object {
1226
- "end": Object {
1227
- "column": 44,
1228
- "line": 4,
1229
- "offset": 83,
1230
- },
1231
- "start": Object {
1232
- "column": 3,
1233
- "line": 4,
1234
- "offset": 42,
1235
- },
1236
- },
1237
- "margin": "",
1238
- "name": "table_row",
1239
- "type": "block",
1240
- },
1241
- Object {
1242
- "content": Array [
1243
- Object {
1244
- "content": Array [
1245
- "Content in the first column",
1246
- ],
1247
- "id": "id",
1248
- "location": Object {
1249
- "end": Object {
1250
- "column": 32,
1251
- "line": 5,
1252
- "offset": 115,
1253
- },
1254
- "start": Object {
1255
- "column": 3,
1256
- "line": 5,
1257
- "offset": 86,
1258
- },
1259
- },
1260
- "margin": "",
1261
- "name": "table_cell",
1262
- "type": "block",
1263
- },
1264
- Object {
1265
- "content": Array [
1266
- "Content in the second column",
1267
- ],
1268
- "id": "id",
1269
- "location": Object {
1270
- "end": Object {
1271
- "column": 61,
1272
- "line": 5,
1273
- "offset": 144,
1274
- },
1275
- "start": Object {
1276
- "column": 32,
1277
- "line": 5,
1278
- "offset": 115,
1279
- },
1280
- },
1281
- "margin": "",
1282
- "name": "table_cell",
1283
- "type": "block",
1284
- },
1285
- ],
1286
- "id": "id",
1287
- "location": Object {
1288
- "end": Object {
1289
- "column": 61,
1290
- "line": 5,
1291
- "offset": 144,
1292
- },
1293
- "start": Object {
1294
- "column": 3,
1295
- "line": 5,
1296
- "offset": 86,
1297
- },
1298
- },
1299
- "margin": "",
1300
- "name": "table_row",
1301
- "type": "block",
1302
- },
1303
- ],
1304
- "id": "id",
1305
- "location": Object {
1306
- "end": Object {
1307
- "column": 61,
1308
- "line": 5,
1309
- "offset": 144,
1310
- },
1311
- "start": Object {
1312
- "column": 3,
1313
- "line": 2,
1314
- "offset": 3,
1315
- },
1316
- },
1317
- "margin": "",
1318
- "name": "table",
1319
- "type": "block",
1320
- },
1321
- ],
1322
- "id": "id",
1323
- "margin": "",
1324
- "name": "root",
1325
- "type": "block",
1326
- }
1327
- `)
1328
- })
1329
-
1330
- it('[markdown]: parse table with align', () => {
1331
- const pod = `
1332
- =markdown
1333
- Left | Centered | Right
1334
- :----------- | :--------------: | -------------------------:
1335
- This is left | Text is centered | And this is right-aligned
1336
- More text | Even more text | And even more to the right
1337
- `
1338
- const tree = process(pod)
1339
- const r = validateAstTree([tree])
1340
- expect(r).toEqual([])
1341
- const errorDescribe = isValidateError(r, tree)
1342
- expect(process(pod)).toMatchInlineSnapshot(`
1343
- Object {
1344
- "content": Array [
1345
- Object {
1346
- "content": Array [
1347
- "=markdown",
1348
- ],
1349
- "id": "id",
1350
- "location": Object {
1351
- "end": Object {
1352
- "column": 10,
1353
- "line": 2,
1354
- "offset": 10,
1355
- },
1356
- "start": Object {
1357
- "column": 1,
1358
- "line": 2,
1359
- "offset": 1,
1360
- },
1361
- },
1362
- "margin": "",
1363
- "text": "text",
1364
- "type": "para",
1365
- },
1366
- Object {
1367
- "align": Array [
1368
- "left",
1369
- "center",
1370
- "right",
1371
- ],
1372
- "content": Array [
1373
- Object {
1374
- "content": Array [
1375
- Object {
1376
- "content": Array [
1377
- "Left",
1378
- ],
1379
- "id": "id",
1380
- "location": Object {
1381
- "end": Object {
1382
- "column": 15,
1383
- "line": 3,
1384
- "offset": 25,
1385
- },
1386
- "start": Object {
1387
- "column": 1,
1388
- "line": 3,
1389
- "offset": 11,
1390
- },
1391
- },
1392
- "margin": "",
1393
- "name": "table_cell",
1394
- "type": "block",
1395
- },
1396
- Object {
1397
- "content": Array [
1398
- "Centered",
1399
- ],
1400
- "id": "id",
1401
- "location": Object {
1402
- "end": Object {
1403
- "column": 34,
1404
- "line": 3,
1405
- "offset": 44,
1406
- },
1407
- "start": Object {
1408
- "column": 15,
1409
- "line": 3,
1410
- "offset": 25,
1411
- },
1412
- },
1413
- "margin": "",
1414
- "name": "table_cell",
1415
- "type": "block",
1416
- },
1417
- Object {
1418
- "content": Array [
1419
- "Right",
1420
- ],
1421
- "id": "id",
1422
- "location": Object {
1423
- "end": Object {
1424
- "column": 40,
1425
- "line": 3,
1426
- "offset": 50,
1427
- },
1428
- "start": Object {
1429
- "column": 34,
1430
- "line": 3,
1431
- "offset": 44,
1432
- },
1433
- },
1434
- "margin": "",
1435
- "name": "table_cell",
1436
- "type": "block",
1437
- },
1438
- ],
1439
- "id": "id",
1440
- "location": Object {
1441
- "end": Object {
1442
- "column": 40,
1443
- "line": 3,
1444
- "offset": 50,
1445
- },
1446
- "start": Object {
1447
- "column": 1,
1448
- "line": 3,
1449
- "offset": 11,
1450
- },
1451
- },
1452
- "margin": "",
1453
- "name": "table_head",
1454
- "type": "block",
1455
- },
1456
- Object {
1457
- "content": Array [
1458
- Object {
1459
- "content": Array [
1460
- "This is left",
1461
- ],
1462
- "id": "id",
1463
- "location": Object {
1464
- "end": Object {
1465
- "column": 15,
1466
- "line": 5,
1467
- "offset": 126,
1468
- },
1469
- "start": Object {
1470
- "column": 1,
1471
- "line": 5,
1472
- "offset": 112,
1473
- },
1474
- },
1475
- "margin": "",
1476
- "name": "table_cell",
1477
- "type": "block",
1478
- },
1479
- Object {
1480
- "content": Array [
1481
- "Text is centered",
1482
- ],
1483
- "id": "id",
1484
- "location": Object {
1485
- "end": Object {
1486
- "column": 34,
1487
- "line": 5,
1488
- "offset": 145,
1489
- },
1490
- "start": Object {
1491
- "column": 15,
1492
- "line": 5,
1493
- "offset": 126,
1494
- },
1495
- },
1496
- "margin": "",
1497
- "name": "table_cell",
1498
- "type": "block",
1499
- },
1500
- Object {
1501
- "content": Array [
1502
- "And this is right-aligned",
1503
- ],
1504
- "id": "id",
1505
- "location": Object {
1506
- "end": Object {
1507
- "column": 60,
1508
- "line": 5,
1509
- "offset": 171,
1510
- },
1511
- "start": Object {
1512
- "column": 34,
1513
- "line": 5,
1514
- "offset": 145,
1515
- },
1516
- },
1517
- "margin": "",
1518
- "name": "table_cell",
1519
- "type": "block",
1520
- },
1521
- ],
1522
- "id": "id",
1523
- "location": Object {
1524
- "end": Object {
1525
- "column": 60,
1526
- "line": 5,
1527
- "offset": 171,
1528
- },
1529
- "start": Object {
1530
- "column": 1,
1531
- "line": 5,
1532
- "offset": 112,
1533
- },
1534
- },
1535
- "margin": "",
1536
- "name": "table_row",
1537
- "type": "block",
1538
- },
1539
- Object {
1540
- "content": Array [
1541
- Object {
1542
- "content": Array [
1543
- "More text",
1544
- ],
1545
- "id": "id",
1546
- "location": Object {
1547
- "end": Object {
1548
- "column": 15,
1549
- "line": 6,
1550
- "offset": 186,
1551
- },
1552
- "start": Object {
1553
- "column": 1,
1554
- "line": 6,
1555
- "offset": 172,
1556
- },
1557
- },
1558
- "margin": "",
1559
- "name": "table_cell",
1560
- "type": "block",
1561
- },
1562
- Object {
1563
- "content": Array [
1564
- "Even more text",
1565
- ],
1566
- "id": "id",
1567
- "location": Object {
1568
- "end": Object {
1569
- "column": 34,
1570
- "line": 6,
1571
- "offset": 205,
1572
- },
1573
- "start": Object {
1574
- "column": 15,
1575
- "line": 6,
1576
- "offset": 186,
1577
- },
1578
- },
1579
- "margin": "",
1580
- "name": "table_cell",
1581
- "type": "block",
1582
- },
1583
- Object {
1584
- "content": Array [
1585
- "And even more to the right",
1586
- ],
1587
- "id": "id",
1588
- "location": Object {
1589
- "end": Object {
1590
- "column": 61,
1591
- "line": 6,
1592
- "offset": 232,
1593
- },
1594
- "start": Object {
1595
- "column": 34,
1596
- "line": 6,
1597
- "offset": 205,
1598
- },
1599
- },
1600
- "margin": "",
1601
- "name": "table_cell",
1602
- "type": "block",
1603
- },
1604
- ],
1605
- "id": "id",
1606
- "location": Object {
1607
- "end": Object {
1608
- "column": 61,
1609
- "line": 6,
1610
- "offset": 232,
1611
- },
1612
- "start": Object {
1613
- "column": 1,
1614
- "line": 6,
1615
- "offset": 172,
1616
- },
1617
- },
1618
- "margin": "",
1619
- "name": "table_row",
1620
- "type": "block",
1621
- },
1622
- ],
1623
- "id": "id",
1624
- "location": Object {
1625
- "end": Object {
1626
- "column": 61,
1627
- "line": 6,
1628
- "offset": 232,
1629
- },
1630
- "start": Object {
1631
- "column": 1,
1632
- "line": 3,
1633
- "offset": 11,
1634
- },
1635
- },
1636
- "margin": "",
1637
- "name": "table",
1638
- "type": "block",
1639
- },
1640
- ],
1641
- "id": "id",
1642
- "margin": "",
1643
- "name": "root",
1644
- "type": "block",
1645
- }
1646
- `)
1647
- })
1648
- it('[markdown]: parse strikethrough', () => {
1649
- const pod = `
1650
- ~~this~~
1651
- `
1652
- const tree = process(pod)
1653
- const r = validateAstTree([tree])
1654
- expect(r).toEqual([])
1655
- const errorDescribe = isValidateError(r, tree)
1656
- expect(process(pod)).toMatchInlineSnapshot(`
1657
- Object {
1658
- "content": Array [
1659
- Object {
1660
- "content": Array [
1661
- Object {
1662
- "content": Array [
1663
- "this",
1664
- ],
1665
- "name": "Delete",
1666
- "type": "fcode",
1667
- },
1668
- ],
1669
- "id": "id",
1670
- "location": Object {
1671
- "end": Object {
1672
- "column": 9,
1673
- "line": 2,
1674
- "offset": 9,
1675
- },
1676
- "start": Object {
1677
- "column": 1,
1678
- "line": 2,
1679
- "offset": 1,
1680
- },
1681
- },
1682
- "margin": "",
1683
- "text": "text",
1684
- "type": "para",
1685
- },
1686
- ],
1687
- "id": "id",
1688
- "margin": "",
1689
- "name": "root",
1690
- "type": "block",
1691
- }
1692
- `)
1693
- })
1694
- it('[markdown]: parse diagrams', () => {
1695
- const pod = `
1696
- \`\`\`mermaid caption="1"
1697
- graph TD;
1698
- A-->B;
1699
- A-->C;
1700
- B-->D;
1701
- C-->D;
1702
- \`\`\`
1703
- `
1704
- const tree = process(pod)
1705
- const r = validateAstTree([tree])
1706
- expect(r).toEqual([])
1707
- expect(process(pod)).toMatchInlineSnapshot(`
1708
- Object {
1709
- "content": Array [
1710
- Object {
1711
- "config": Array [],
1712
- "content": Array [
1713
- Object {
1714
- "type": "verbatim",
1715
- "value": "graph TD;
1716
- A-->B;
1717
- A-->C;
1718
- B-->D;
1719
- C-->D;",
1720
- },
1721
- ],
1722
- "id": "id",
1723
- "location": Object {
1724
- "end": Object {
1725
- "column": 4,
1726
- "line": 8,
1727
- "offset": 81,
1728
- },
1729
- "start": Object {
1730
- "column": 1,
1731
- "line": 2,
1732
- "offset": 1,
1733
- },
1734
- },
1735
- "margin": "",
1736
- "name": "Mermaid",
1737
- "type": "block",
1738
- },
1739
- ],
1740
- "id": "id",
1741
- "margin": "",
1742
- "name": "root",
1743
- "type": "block",
1744
- }
1745
- `)
1746
- })
1747
- it('[markdown]: parse formulas', () => {
1748
- const pod = `
1749
- test \$x+1\over\sqrt{1-x^2}\$
1750
-
1751
- $$
1752
- L = \frac{1}{2} \rho v^2 S C_L
1753
- tes
1754
- $$
1755
- `
1756
- const tree = process(pod)
1757
-
1758
- const r = validateAstTree([tree])
1759
- expect(r).toEqual([])
1760
- // expect(process(pod)).toMatchInlineSnapshot()
1761
- // console.log(JSON.stringify(tree, null, 2))
1762
- })
1763
-
1764
- it('[markdown]: parse images', () => {
1765
- const pod = `
1766
- [![Build Status](https://example.com/image.png)](https://example.org)
1767
-
1768
- `
1769
- const tree = process(pod)
1770
- expect(process(pod)).toMatchInlineSnapshot(`
1771
- Object {
1772
- "content": Array [
1773
- Object {
1774
- "content": Array [
1775
- Object {
1776
- "content": Array [
1777
- Object {
1778
- "config": Array [],
1779
- "content": Array [
1780
- Object {
1781
- "alt": "Build Status",
1782
- "src": "https://example.com/image.png",
1783
- "type": "image",
1784
- },
1785
- ],
1786
- "id": "id",
1787
- "location": Object {
1788
- "end": Object {
1789
- "column": 48,
1790
- "line": 2,
1791
- "offset": 48,
1792
- },
1793
- "start": Object {
1794
- "column": 2,
1795
- "line": 2,
1796
- "offset": 2,
1797
- },
1798
- },
1799
- "margin": "",
1800
- "name": "Image",
1801
- "type": "block",
1802
- },
1803
- ],
1804
- "meta": "https://example.org",
1805
- "name": "L",
1806
- "type": "fcode",
1807
- },
1808
- ],
1809
- "id": "id",
1810
- "location": Object {
1811
- "end": Object {
1812
- "column": 70,
1813
- "line": 2,
1814
- "offset": 70,
1815
- },
1816
- "start": Object {
1817
- "column": 1,
1818
- "line": 2,
1819
- "offset": 1,
1820
- },
1821
- },
1822
- "margin": "",
1823
- "text": "text",
1824
- "type": "para",
1825
- },
1826
- ],
1827
- "id": "id",
1828
- "margin": "",
1829
- "name": "root",
1830
- "type": "block",
1831
- }
1832
- `)
1833
- })