@podlite/markdown 0.0.31 → 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,1854 +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
- "config": Array [
890
- Object {
891
- "name": "header",
892
- "type": "boolean",
893
- "value": true,
894
- },
895
- ],
896
- "content": Array [
897
- Object {
898
- "content": Array [
899
- "First Header",
900
- ],
901
- "id": "id",
902
- "location": Object {
903
- "end": Object {
904
- "column": 15,
905
- "line": 2,
906
- "offset": 15,
907
- },
908
- "start": Object {
909
- "column": 1,
910
- "line": 2,
911
- "offset": 1,
912
- },
913
- },
914
- "margin": "",
915
- "name": "cell",
916
- "type": "block",
917
- },
918
- Object {
919
- "content": Array [
920
- "Second Header",
921
- ],
922
- "id": "id",
923
- "location": Object {
924
- "end": Object {
925
- "column": 29,
926
- "line": 2,
927
- "offset": 29,
928
- },
929
- "start": Object {
930
- "column": 15,
931
- "line": 2,
932
- "offset": 15,
933
- },
934
- },
935
- "margin": "",
936
- "name": "cell",
937
- "type": "block",
938
- },
939
- ],
940
- "id": "id",
941
- "location": Object {
942
- "end": Object {
943
- "column": 29,
944
- "line": 2,
945
- "offset": 29,
946
- },
947
- "start": Object {
948
- "column": 1,
949
- "line": 2,
950
- "offset": 1,
951
- },
952
- },
953
- "margin": "",
954
- "name": "row",
955
- "type": "block",
956
- },
957
- Object {
958
- "content": Array [
959
- Object {
960
- "content": Array [
961
- "Content from cell 1",
962
- ],
963
- "id": "id",
964
- "location": Object {
965
- "end": Object {
966
- "column": 22,
967
- "line": 4,
968
- "offset": 80,
969
- },
970
- "start": Object {
971
- "column": 1,
972
- "line": 4,
973
- "offset": 59,
974
- },
975
- },
976
- "margin": "",
977
- "name": "cell",
978
- "type": "block",
979
- },
980
- Object {
981
- "content": Array [
982
- "Content from cell 2",
983
- ],
984
- "id": "id",
985
- "location": Object {
986
- "end": Object {
987
- "column": 42,
988
- "line": 4,
989
- "offset": 100,
990
- },
991
- "start": Object {
992
- "column": 22,
993
- "line": 4,
994
- "offset": 80,
995
- },
996
- },
997
- "margin": "",
998
- "name": "cell",
999
- "type": "block",
1000
- },
1001
- ],
1002
- "id": "id",
1003
- "location": Object {
1004
- "end": Object {
1005
- "column": 42,
1006
- "line": 4,
1007
- "offset": 100,
1008
- },
1009
- "start": Object {
1010
- "column": 1,
1011
- "line": 4,
1012
- "offset": 59,
1013
- },
1014
- },
1015
- "margin": "",
1016
- "name": "row",
1017
- "type": "block",
1018
- },
1019
- Object {
1020
- "content": Array [
1021
- Object {
1022
- "content": Array [
1023
- "Content in the first column",
1024
- ],
1025
- "id": "id",
1026
- "location": Object {
1027
- "end": Object {
1028
- "column": 30,
1029
- "line": 5,
1030
- "offset": 130,
1031
- },
1032
- "start": Object {
1033
- "column": 1,
1034
- "line": 5,
1035
- "offset": 101,
1036
- },
1037
- },
1038
- "margin": "",
1039
- "name": "cell",
1040
- "type": "block",
1041
- },
1042
- Object {
1043
- "content": Array [
1044
- "Content in the second column",
1045
- ],
1046
- "id": "id",
1047
- "location": Object {
1048
- "end": Object {
1049
- "column": 59,
1050
- "line": 5,
1051
- "offset": 159,
1052
- },
1053
- "start": Object {
1054
- "column": 30,
1055
- "line": 5,
1056
- "offset": 130,
1057
- },
1058
- },
1059
- "margin": "",
1060
- "name": "cell",
1061
- "type": "block",
1062
- },
1063
- ],
1064
- "id": "id",
1065
- "location": Object {
1066
- "end": Object {
1067
- "column": 59,
1068
- "line": 5,
1069
- "offset": 159,
1070
- },
1071
- "start": Object {
1072
- "column": 1,
1073
- "line": 5,
1074
- "offset": 101,
1075
- },
1076
- },
1077
- "margin": "",
1078
- "name": "row",
1079
- "type": "block",
1080
- },
1081
- ],
1082
- "id": "id",
1083
- "location": Object {
1084
- "end": Object {
1085
- "column": 59,
1086
- "line": 5,
1087
- "offset": 159,
1088
- },
1089
- "start": Object {
1090
- "column": 1,
1091
- "line": 2,
1092
- "offset": 1,
1093
- },
1094
- },
1095
- "margin": "",
1096
- "name": "table",
1097
- "type": "block",
1098
- },
1099
- ],
1100
- "id": "id",
1101
- "margin": "",
1102
- "name": "root",
1103
- "type": "block",
1104
- }
1105
- `)
1106
- })
1107
-
1108
- it('[markdown]: parse table with empty header', () => {
1109
- const pod = `
1110
- | | |
1111
- ------------ | -------------
1112
- Content from cell 1 | Content from cell 2
1113
- Content in the first column | Content in the second column
1114
- `
1115
- const tree = process(pod)
1116
- const r = validateAstTree([tree])
1117
- expect(r).toEqual([])
1118
- const errorDescribe = isValidateError(r, tree)
1119
- expect(process(pod)).toMatchInlineSnapshot(`
1120
- Object {
1121
- "content": Array [
1122
- Object {
1123
- "align": Array [
1124
- null,
1125
- null,
1126
- ],
1127
- "content": Array [
1128
- Object {
1129
- "config": Array [
1130
- Object {
1131
- "name": "header",
1132
- "type": "boolean",
1133
- "value": true,
1134
- },
1135
- ],
1136
- "content": Array [
1137
- Object {
1138
- "content": Array [],
1139
- "id": "id",
1140
- "location": Object {
1141
- "end": Object {
1142
- "column": 6,
1143
- "line": 2,
1144
- "offset": 6,
1145
- },
1146
- "start": Object {
1147
- "column": 3,
1148
- "line": 2,
1149
- "offset": 3,
1150
- },
1151
- },
1152
- "margin": "",
1153
- "name": "cell",
1154
- "type": "block",
1155
- },
1156
- Object {
1157
- "content": Array [],
1158
- "id": "id",
1159
- "location": Object {
1160
- "end": Object {
1161
- "column": 8,
1162
- "line": 2,
1163
- "offset": 8,
1164
- },
1165
- "start": Object {
1166
- "column": 6,
1167
- "line": 2,
1168
- "offset": 6,
1169
- },
1170
- },
1171
- "margin": "",
1172
- "name": "cell",
1173
- "type": "block",
1174
- },
1175
- ],
1176
- "id": "id",
1177
- "location": Object {
1178
- "end": Object {
1179
- "column": 8,
1180
- "line": 2,
1181
- "offset": 8,
1182
- },
1183
- "start": Object {
1184
- "column": 3,
1185
- "line": 2,
1186
- "offset": 3,
1187
- },
1188
- },
1189
- "margin": "",
1190
- "name": "row",
1191
- "type": "block",
1192
- },
1193
- Object {
1194
- "content": Array [
1195
- Object {
1196
- "content": Array [
1197
- "Content from cell 1",
1198
- ],
1199
- "id": "id",
1200
- "location": Object {
1201
- "end": Object {
1202
- "column": 24,
1203
- "line": 4,
1204
- "offset": 63,
1205
- },
1206
- "start": Object {
1207
- "column": 3,
1208
- "line": 4,
1209
- "offset": 42,
1210
- },
1211
- },
1212
- "margin": "",
1213
- "name": "cell",
1214
- "type": "block",
1215
- },
1216
- Object {
1217
- "content": Array [
1218
- "Content from cell 2",
1219
- ],
1220
- "id": "id",
1221
- "location": Object {
1222
- "end": Object {
1223
- "column": 44,
1224
- "line": 4,
1225
- "offset": 83,
1226
- },
1227
- "start": Object {
1228
- "column": 24,
1229
- "line": 4,
1230
- "offset": 63,
1231
- },
1232
- },
1233
- "margin": "",
1234
- "name": "cell",
1235
- "type": "block",
1236
- },
1237
- ],
1238
- "id": "id",
1239
- "location": Object {
1240
- "end": Object {
1241
- "column": 44,
1242
- "line": 4,
1243
- "offset": 83,
1244
- },
1245
- "start": Object {
1246
- "column": 3,
1247
- "line": 4,
1248
- "offset": 42,
1249
- },
1250
- },
1251
- "margin": "",
1252
- "name": "row",
1253
- "type": "block",
1254
- },
1255
- Object {
1256
- "content": Array [
1257
- Object {
1258
- "content": Array [
1259
- "Content in the first column",
1260
- ],
1261
- "id": "id",
1262
- "location": Object {
1263
- "end": Object {
1264
- "column": 32,
1265
- "line": 5,
1266
- "offset": 115,
1267
- },
1268
- "start": Object {
1269
- "column": 3,
1270
- "line": 5,
1271
- "offset": 86,
1272
- },
1273
- },
1274
- "margin": "",
1275
- "name": "cell",
1276
- "type": "block",
1277
- },
1278
- Object {
1279
- "content": Array [
1280
- "Content in the second column",
1281
- ],
1282
- "id": "id",
1283
- "location": Object {
1284
- "end": Object {
1285
- "column": 61,
1286
- "line": 5,
1287
- "offset": 144,
1288
- },
1289
- "start": Object {
1290
- "column": 32,
1291
- "line": 5,
1292
- "offset": 115,
1293
- },
1294
- },
1295
- "margin": "",
1296
- "name": "cell",
1297
- "type": "block",
1298
- },
1299
- ],
1300
- "id": "id",
1301
- "location": Object {
1302
- "end": Object {
1303
- "column": 61,
1304
- "line": 5,
1305
- "offset": 144,
1306
- },
1307
- "start": Object {
1308
- "column": 3,
1309
- "line": 5,
1310
- "offset": 86,
1311
- },
1312
- },
1313
- "margin": "",
1314
- "name": "row",
1315
- "type": "block",
1316
- },
1317
- ],
1318
- "id": "id",
1319
- "location": Object {
1320
- "end": Object {
1321
- "column": 61,
1322
- "line": 5,
1323
- "offset": 144,
1324
- },
1325
- "start": Object {
1326
- "column": 3,
1327
- "line": 2,
1328
- "offset": 3,
1329
- },
1330
- },
1331
- "margin": "",
1332
- "name": "table",
1333
- "type": "block",
1334
- },
1335
- ],
1336
- "id": "id",
1337
- "margin": "",
1338
- "name": "root",
1339
- "type": "block",
1340
- }
1341
- `)
1342
- })
1343
-
1344
- it('[markdown]: parse table with align', () => {
1345
- const pod = `
1346
- =markdown
1347
- Left | Centered | Right
1348
- :----------- | :--------------: | -------------------------:
1349
- This is left | Text is centered | And this is right-aligned
1350
- More text | Even more text | And even more to the right
1351
- `
1352
- const tree = process(pod)
1353
- const r = validateAstTree([tree])
1354
- expect(r).toEqual([])
1355
- const errorDescribe = isValidateError(r, tree)
1356
- expect(process(pod)).toMatchInlineSnapshot(`
1357
- Object {
1358
- "content": Array [
1359
- Object {
1360
- "content": Array [
1361
- "=markdown",
1362
- ],
1363
- "id": "id",
1364
- "location": Object {
1365
- "end": Object {
1366
- "column": 10,
1367
- "line": 2,
1368
- "offset": 10,
1369
- },
1370
- "start": Object {
1371
- "column": 1,
1372
- "line": 2,
1373
- "offset": 1,
1374
- },
1375
- },
1376
- "margin": "",
1377
- "text": "text",
1378
- "type": "para",
1379
- },
1380
- Object {
1381
- "align": Array [
1382
- "left",
1383
- "center",
1384
- "right",
1385
- ],
1386
- "content": Array [
1387
- Object {
1388
- "config": Array [
1389
- Object {
1390
- "name": "header",
1391
- "type": "boolean",
1392
- "value": true,
1393
- },
1394
- ],
1395
- "content": Array [
1396
- Object {
1397
- "content": Array [
1398
- "Left",
1399
- ],
1400
- "id": "id",
1401
- "location": Object {
1402
- "end": Object {
1403
- "column": 15,
1404
- "line": 3,
1405
- "offset": 25,
1406
- },
1407
- "start": Object {
1408
- "column": 1,
1409
- "line": 3,
1410
- "offset": 11,
1411
- },
1412
- },
1413
- "margin": "",
1414
- "name": "cell",
1415
- "type": "block",
1416
- },
1417
- Object {
1418
- "content": Array [
1419
- "Centered",
1420
- ],
1421
- "id": "id",
1422
- "location": Object {
1423
- "end": Object {
1424
- "column": 34,
1425
- "line": 3,
1426
- "offset": 44,
1427
- },
1428
- "start": Object {
1429
- "column": 15,
1430
- "line": 3,
1431
- "offset": 25,
1432
- },
1433
- },
1434
- "margin": "",
1435
- "name": "cell",
1436
- "type": "block",
1437
- },
1438
- Object {
1439
- "content": Array [
1440
- "Right",
1441
- ],
1442
- "id": "id",
1443
- "location": Object {
1444
- "end": Object {
1445
- "column": 40,
1446
- "line": 3,
1447
- "offset": 50,
1448
- },
1449
- "start": Object {
1450
- "column": 34,
1451
- "line": 3,
1452
- "offset": 44,
1453
- },
1454
- },
1455
- "margin": "",
1456
- "name": "cell",
1457
- "type": "block",
1458
- },
1459
- ],
1460
- "id": "id",
1461
- "location": Object {
1462
- "end": Object {
1463
- "column": 40,
1464
- "line": 3,
1465
- "offset": 50,
1466
- },
1467
- "start": Object {
1468
- "column": 1,
1469
- "line": 3,
1470
- "offset": 11,
1471
- },
1472
- },
1473
- "margin": "",
1474
- "name": "row",
1475
- "type": "block",
1476
- },
1477
- Object {
1478
- "content": Array [
1479
- Object {
1480
- "content": Array [
1481
- "This is left",
1482
- ],
1483
- "id": "id",
1484
- "location": Object {
1485
- "end": Object {
1486
- "column": 15,
1487
- "line": 5,
1488
- "offset": 126,
1489
- },
1490
- "start": Object {
1491
- "column": 1,
1492
- "line": 5,
1493
- "offset": 112,
1494
- },
1495
- },
1496
- "margin": "",
1497
- "name": "cell",
1498
- "type": "block",
1499
- },
1500
- Object {
1501
- "content": Array [
1502
- "Text is centered",
1503
- ],
1504
- "id": "id",
1505
- "location": Object {
1506
- "end": Object {
1507
- "column": 34,
1508
- "line": 5,
1509
- "offset": 145,
1510
- },
1511
- "start": Object {
1512
- "column": 15,
1513
- "line": 5,
1514
- "offset": 126,
1515
- },
1516
- },
1517
- "margin": "",
1518
- "name": "cell",
1519
- "type": "block",
1520
- },
1521
- Object {
1522
- "content": Array [
1523
- "And this is right-aligned",
1524
- ],
1525
- "id": "id",
1526
- "location": Object {
1527
- "end": Object {
1528
- "column": 60,
1529
- "line": 5,
1530
- "offset": 171,
1531
- },
1532
- "start": Object {
1533
- "column": 34,
1534
- "line": 5,
1535
- "offset": 145,
1536
- },
1537
- },
1538
- "margin": "",
1539
- "name": "cell",
1540
- "type": "block",
1541
- },
1542
- ],
1543
- "id": "id",
1544
- "location": Object {
1545
- "end": Object {
1546
- "column": 60,
1547
- "line": 5,
1548
- "offset": 171,
1549
- },
1550
- "start": Object {
1551
- "column": 1,
1552
- "line": 5,
1553
- "offset": 112,
1554
- },
1555
- },
1556
- "margin": "",
1557
- "name": "row",
1558
- "type": "block",
1559
- },
1560
- Object {
1561
- "content": Array [
1562
- Object {
1563
- "content": Array [
1564
- "More text",
1565
- ],
1566
- "id": "id",
1567
- "location": Object {
1568
- "end": Object {
1569
- "column": 15,
1570
- "line": 6,
1571
- "offset": 186,
1572
- },
1573
- "start": Object {
1574
- "column": 1,
1575
- "line": 6,
1576
- "offset": 172,
1577
- },
1578
- },
1579
- "margin": "",
1580
- "name": "cell",
1581
- "type": "block",
1582
- },
1583
- Object {
1584
- "content": Array [
1585
- "Even more text",
1586
- ],
1587
- "id": "id",
1588
- "location": Object {
1589
- "end": Object {
1590
- "column": 34,
1591
- "line": 6,
1592
- "offset": 205,
1593
- },
1594
- "start": Object {
1595
- "column": 15,
1596
- "line": 6,
1597
- "offset": 186,
1598
- },
1599
- },
1600
- "margin": "",
1601
- "name": "cell",
1602
- "type": "block",
1603
- },
1604
- Object {
1605
- "content": Array [
1606
- "And even more to the right",
1607
- ],
1608
- "id": "id",
1609
- "location": Object {
1610
- "end": Object {
1611
- "column": 61,
1612
- "line": 6,
1613
- "offset": 232,
1614
- },
1615
- "start": Object {
1616
- "column": 34,
1617
- "line": 6,
1618
- "offset": 205,
1619
- },
1620
- },
1621
- "margin": "",
1622
- "name": "cell",
1623
- "type": "block",
1624
- },
1625
- ],
1626
- "id": "id",
1627
- "location": Object {
1628
- "end": Object {
1629
- "column": 61,
1630
- "line": 6,
1631
- "offset": 232,
1632
- },
1633
- "start": Object {
1634
- "column": 1,
1635
- "line": 6,
1636
- "offset": 172,
1637
- },
1638
- },
1639
- "margin": "",
1640
- "name": "row",
1641
- "type": "block",
1642
- },
1643
- ],
1644
- "id": "id",
1645
- "location": Object {
1646
- "end": Object {
1647
- "column": 61,
1648
- "line": 6,
1649
- "offset": 232,
1650
- },
1651
- "start": Object {
1652
- "column": 1,
1653
- "line": 3,
1654
- "offset": 11,
1655
- },
1656
- },
1657
- "margin": "",
1658
- "name": "table",
1659
- "type": "block",
1660
- },
1661
- ],
1662
- "id": "id",
1663
- "margin": "",
1664
- "name": "root",
1665
- "type": "block",
1666
- }
1667
- `)
1668
- })
1669
- it('[markdown]: parse strikethrough', () => {
1670
- const pod = `
1671
- ~~this~~
1672
- `
1673
- const tree = process(pod)
1674
- const r = validateAstTree([tree])
1675
- expect(r).toEqual([])
1676
- const errorDescribe = isValidateError(r, tree)
1677
- expect(process(pod)).toMatchInlineSnapshot(`
1678
- Object {
1679
- "content": Array [
1680
- Object {
1681
- "content": Array [
1682
- Object {
1683
- "content": Array [
1684
- "this",
1685
- ],
1686
- "name": "O",
1687
- "type": "fcode",
1688
- },
1689
- ],
1690
- "id": "id",
1691
- "location": Object {
1692
- "end": Object {
1693
- "column": 9,
1694
- "line": 2,
1695
- "offset": 9,
1696
- },
1697
- "start": Object {
1698
- "column": 1,
1699
- "line": 2,
1700
- "offset": 1,
1701
- },
1702
- },
1703
- "margin": "",
1704
- "text": "text",
1705
- "type": "para",
1706
- },
1707
- ],
1708
- "id": "id",
1709
- "margin": "",
1710
- "name": "root",
1711
- "type": "block",
1712
- }
1713
- `)
1714
- })
1715
- it('[markdown]: parse diagrams', () => {
1716
- const pod = `
1717
- \`\`\`mermaid caption="1"
1718
- graph TD;
1719
- A-->B;
1720
- A-->C;
1721
- B-->D;
1722
- C-->D;
1723
- \`\`\`
1724
- `
1725
- const tree = process(pod)
1726
- const r = validateAstTree([tree])
1727
- expect(r).toEqual([])
1728
- expect(process(pod)).toMatchInlineSnapshot(`
1729
- Object {
1730
- "content": Array [
1731
- Object {
1732
- "config": Array [],
1733
- "content": Array [
1734
- Object {
1735
- "type": "verbatim",
1736
- "value": "graph TD;
1737
- A-->B;
1738
- A-->C;
1739
- B-->D;
1740
- C-->D;",
1741
- },
1742
- ],
1743
- "id": "id",
1744
- "location": Object {
1745
- "end": Object {
1746
- "column": 4,
1747
- "line": 8,
1748
- "offset": 81,
1749
- },
1750
- "start": Object {
1751
- "column": 1,
1752
- "line": 2,
1753
- "offset": 1,
1754
- },
1755
- },
1756
- "margin": "",
1757
- "name": "Mermaid",
1758
- "type": "block",
1759
- },
1760
- ],
1761
- "id": "id",
1762
- "margin": "",
1763
- "name": "root",
1764
- "type": "block",
1765
- }
1766
- `)
1767
- })
1768
- it('[markdown]: parse formulas', () => {
1769
- const pod = `
1770
- test \$x+1\over\sqrt{1-x^2}\$
1771
-
1772
- $$
1773
- L = \frac{1}{2} \rho v^2 S C_L
1774
- tes
1775
- $$
1776
- `
1777
- const tree = process(pod)
1778
-
1779
- const r = validateAstTree([tree])
1780
- expect(r).toEqual([])
1781
- // expect(process(pod)).toMatchInlineSnapshot()
1782
- // console.log(JSON.stringify(tree, null, 2))
1783
- })
1784
-
1785
- it('[markdown]: parse images', () => {
1786
- const pod = `
1787
- [![Build Status](https://example.com/image.png)](https://example.org)
1788
-
1789
- `
1790
- const tree = process(pod)
1791
- expect(process(pod)).toMatchInlineSnapshot(`
1792
- Object {
1793
- "content": Array [
1794
- Object {
1795
- "content": Array [
1796
- Object {
1797
- "content": Array [
1798
- Object {
1799
- "config": Array [],
1800
- "content": Array [
1801
- Object {
1802
- "alt": "Build Status",
1803
- "src": "https://example.com/image.png",
1804
- "type": "image",
1805
- },
1806
- ],
1807
- "id": "id",
1808
- "location": Object {
1809
- "end": Object {
1810
- "column": 48,
1811
- "line": 2,
1812
- "offset": 48,
1813
- },
1814
- "start": Object {
1815
- "column": 2,
1816
- "line": 2,
1817
- "offset": 2,
1818
- },
1819
- },
1820
- "margin": "",
1821
- "name": "Image",
1822
- "type": "block",
1823
- },
1824
- ],
1825
- "meta": "https://example.org",
1826
- "name": "L",
1827
- "type": "fcode",
1828
- },
1829
- ],
1830
- "id": "id",
1831
- "location": Object {
1832
- "end": Object {
1833
- "column": 70,
1834
- "line": 2,
1835
- "offset": 70,
1836
- },
1837
- "start": Object {
1838
- "column": 1,
1839
- "line": 2,
1840
- "offset": 1,
1841
- },
1842
- },
1843
- "margin": "",
1844
- "text": "text",
1845
- "type": "para",
1846
- },
1847
- ],
1848
- "id": "id",
1849
- "margin": "",
1850
- "name": "root",
1851
- "type": "block",
1852
- }
1853
- `)
1854
- })