@podlite/to-jsx 0.0.7 → 0.0.8
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/CHANGELOG.md +4 -1
- package/lib/index.js +85 -29
- package/package.json +20 -19
- package/src/index.tsx +57 -21
- package/t/index.component.spec.tsx +147 -9
- package/tsconfig.tsbuildinfo +1 -1995
- package/yarn-error.log +8944 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import Podlite from "../src/index";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import ReactDOM from "react-dom";
|
|
4
|
+
import { podlite as podlite_core, PodliteExport } from "podlite";
|
|
5
|
+
import { cleanIds, frozenIds } from "podlite";
|
|
4
6
|
|
|
5
7
|
const root = document.body.appendChild(document.createElement("div"));
|
|
6
8
|
|
|
@@ -9,9 +11,20 @@ function render(jsx) {
|
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
afterEach(() => ReactDOM.unmountComponentAtNode(root));
|
|
14
|
+
const CPodlite = ({ children, ...options }) => {
|
|
15
|
+
let podlite = podlite_core({ importPlugins: true });
|
|
12
16
|
|
|
17
|
+
let treeAfterParsed = frozenIds()(podlite.parse(children));
|
|
18
|
+
|
|
19
|
+
const tree = podlite.toAst(treeAfterParsed);
|
|
20
|
+
return (
|
|
21
|
+
<Podlite
|
|
22
|
+
{...{ children, ...options, tree: { interator: tree } as PodliteExport }}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
13
26
|
it("para content", () => {
|
|
14
|
-
render(<
|
|
27
|
+
render(<CPodlite>Hello!</CPodlite>);
|
|
15
28
|
|
|
16
29
|
expect(root.innerHTML).toMatchInlineSnapshot(`
|
|
17
30
|
<p>
|
|
@@ -22,7 +35,7 @@ it("para content", () => {
|
|
|
22
35
|
|
|
23
36
|
it("table", () => {
|
|
24
37
|
render(
|
|
25
|
-
<
|
|
38
|
+
<CPodlite>
|
|
26
39
|
{`
|
|
27
40
|
=begin pod
|
|
28
41
|
=para test
|
|
@@ -45,7 +58,7 @@ sdsdsd
|
|
|
45
58
|
=end table
|
|
46
59
|
=end pod
|
|
47
60
|
`}
|
|
48
|
-
</
|
|
61
|
+
</CPodlite>
|
|
49
62
|
);
|
|
50
63
|
expect(root.innerHTML).toMatchInlineSnapshot(`
|
|
51
64
|
<div>
|
|
@@ -55,11 +68,11 @@ sdsdsd
|
|
|
55
68
|
sdsdsd
|
|
56
69
|
</p>
|
|
57
70
|
</div>
|
|
58
|
-
<h1>
|
|
71
|
+
<h1 id="id">
|
|
59
72
|
Test
|
|
60
73
|
</h1>
|
|
61
74
|
<table>
|
|
62
|
-
<caption>
|
|
75
|
+
<caption class="caption">
|
|
63
76
|
Super table!
|
|
64
77
|
</caption>
|
|
65
78
|
<tbody>
|
|
@@ -420,25 +433,102 @@ it("accepts U<>, X<>, S<>", () => {
|
|
|
420
433
|
`);
|
|
421
434
|
});
|
|
422
435
|
|
|
423
|
-
it("accepts =Image", () => {
|
|
436
|
+
it("accepts =Image base", () => {
|
|
424
437
|
render(
|
|
425
438
|
<Podlite>
|
|
426
439
|
{`
|
|
427
440
|
=begin pod
|
|
428
|
-
=Image
|
|
441
|
+
=for Image :id<1> :caption<A picture of a cat> :link<https://example.com/cat.jpg>
|
|
442
|
+
alternative https://www.example.org
|
|
429
443
|
=end pod
|
|
430
444
|
`}
|
|
431
445
|
</Podlite>
|
|
432
446
|
);
|
|
433
447
|
expect(root.innerHTML).toMatchInlineSnapshot(`
|
|
434
448
|
<div>
|
|
435
|
-
<
|
|
436
|
-
|
|
449
|
+
<div class="image_block"
|
|
450
|
+
id="1"
|
|
451
|
+
>
|
|
452
|
+
<a href="https://example.com/cat.jpg">
|
|
453
|
+
<img src="https://www.example.org"
|
|
454
|
+
alt="alternative"
|
|
455
|
+
>
|
|
456
|
+
</a>
|
|
457
|
+
<div class="caption">
|
|
458
|
+
<p>
|
|
459
|
+
A picture of a cat
|
|
460
|
+
</p>
|
|
461
|
+
</div>
|
|
462
|
+
</div>
|
|
463
|
+
</div>
|
|
464
|
+
`);
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
it("accepts =Image empty caption", () => {
|
|
468
|
+
render(
|
|
469
|
+
<Podlite>
|
|
470
|
+
{`
|
|
471
|
+
=begin pod
|
|
472
|
+
=for Image :id<1> :link<https://example.com/cat.jpg>
|
|
473
|
+
alternative https://www.example.org
|
|
474
|
+
=end pod
|
|
475
|
+
`}
|
|
476
|
+
</Podlite>
|
|
477
|
+
);
|
|
478
|
+
// console.log(root.innerHTML);return;
|
|
479
|
+
expect(root.innerHTML).toMatchInlineSnapshot(`
|
|
480
|
+
<div>
|
|
481
|
+
<div class="image_block"
|
|
482
|
+
id="1"
|
|
437
483
|
>
|
|
484
|
+
<a href="https://example.com/cat.jpg">
|
|
485
|
+
<img src="https://www.example.org"
|
|
486
|
+
alt="alternative"
|
|
487
|
+
>
|
|
488
|
+
</a>
|
|
489
|
+
</div>
|
|
438
490
|
</div>
|
|
491
|
+
<p>
|
|
492
|
+
</p>
|
|
439
493
|
`);
|
|
440
494
|
});
|
|
441
495
|
|
|
496
|
+
it("accepts =Image with fullset of attributes", () => {
|
|
497
|
+
render(
|
|
498
|
+
<Podlite>
|
|
499
|
+
{`
|
|
500
|
+
=begin pod
|
|
501
|
+
=for Image :alt<alternative>
|
|
502
|
+
= :link<'https://www.example.org'>
|
|
503
|
+
= :src<'https://www.example.org'>
|
|
504
|
+
= :caption<'caption'>
|
|
505
|
+
= :id<'id'>
|
|
506
|
+
content ignored
|
|
507
|
+
=end pod
|
|
508
|
+
`}
|
|
509
|
+
</Podlite>
|
|
510
|
+
);
|
|
511
|
+
expect(root.innerHTML).toMatchInlineSnapshot(`
|
|
512
|
+
<div>
|
|
513
|
+
<div class="image_block"
|
|
514
|
+
id="id"
|
|
515
|
+
>
|
|
516
|
+
<a href="https://www.example.org">
|
|
517
|
+
<img src="https://www.example.org"
|
|
518
|
+
alt="alternative"
|
|
519
|
+
>
|
|
520
|
+
</a>
|
|
521
|
+
<div class="caption">
|
|
522
|
+
<p>
|
|
523
|
+
caption
|
|
524
|
+
</p>
|
|
525
|
+
</div>
|
|
526
|
+
</div>
|
|
527
|
+
</div>
|
|
528
|
+
<p>
|
|
529
|
+
</p>
|
|
530
|
+
`);
|
|
531
|
+
});
|
|
442
532
|
it("accepts =TITLE", () => {
|
|
443
533
|
render(
|
|
444
534
|
<Podlite>
|
|
@@ -540,6 +630,54 @@ but some of us are looking at the stars!
|
|
|
540
630
|
`);
|
|
541
631
|
});
|
|
542
632
|
|
|
633
|
+
it("accepts =Toc", () => {
|
|
634
|
+
render(
|
|
635
|
+
<Podlite>
|
|
636
|
+
{`
|
|
637
|
+
=begin pod
|
|
638
|
+
=Toc head1 item
|
|
639
|
+
=for head1 :id<Test>
|
|
640
|
+
head1
|
|
641
|
+
=for item1 :id<item>
|
|
642
|
+
item1
|
|
643
|
+
=end pod
|
|
644
|
+
`}
|
|
645
|
+
</Podlite>
|
|
646
|
+
);
|
|
647
|
+
expect(root.innerHTML).toMatchInlineSnapshot(`
|
|
648
|
+
<div>
|
|
649
|
+
<div class="toc">
|
|
650
|
+
<ul class="toc-list listlevel1">
|
|
651
|
+
<li class="toc-item">
|
|
652
|
+
<a href="#Test">
|
|
653
|
+
head1
|
|
654
|
+
</a>
|
|
655
|
+
</li>
|
|
656
|
+
<ul class="toc-list listlevel2">
|
|
657
|
+
<li class="toc-item">
|
|
658
|
+
<a href="#item">
|
|
659
|
+
item1
|
|
660
|
+
</a>
|
|
661
|
+
</li>
|
|
662
|
+
</ul>
|
|
663
|
+
</ul>
|
|
664
|
+
</div>
|
|
665
|
+
<h1 id="Test">
|
|
666
|
+
head1
|
|
667
|
+
</h1>
|
|
668
|
+
<ul>
|
|
669
|
+
<li id="item">
|
|
670
|
+
<p>
|
|
671
|
+
item1
|
|
672
|
+
</p>
|
|
673
|
+
</li>
|
|
674
|
+
</ul>
|
|
675
|
+
</div>
|
|
676
|
+
<p>
|
|
677
|
+
</p>
|
|
678
|
+
`);
|
|
679
|
+
});
|
|
680
|
+
|
|
543
681
|
it.skip("accepts =Diagram", () => {
|
|
544
682
|
render(
|
|
545
683
|
<Podlite>
|