@podlite/to-jsx 0.0.18 → 0.0.20

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.
@@ -1,720 +0,0 @@
1
- import { TestPodlite as Podlite, Podlite as PodliteRaw } from '../src/index'
2
- import React from 'react'
3
- import { renderToStaticMarkup } from 'react-dom/server'
4
-
5
- const root = { innerHTML: '' }
6
- function render(jsx) {
7
- root.innerHTML = renderToStaticMarkup(jsx)
8
- return root.innerHTML
9
- }
10
-
11
- it('para content', () => {
12
- render(<Podlite>Hello!</Podlite>)
13
-
14
- expect(root.innerHTML).toMatchInlineSnapshot(`
15
- <p>
16
- Hello!
17
- </p>
18
- `)
19
- })
20
-
21
- it('table', () => {
22
- expect(
23
- render(
24
- <Podlite>
25
- {`
26
- =begin pod
27
- =para test
28
- sdsdsd
29
- =head1 Test
30
- =begin table :caption('Super table!')
31
- Secret
32
- Superhero Identity Superpower
33
- ============= =============== ===================
34
- The Shoveller Eddie Stevens King Arthur's
35
- singing shovel
36
-
37
- Blue Raja Geoffrey Smith Master of cutlery
38
-
39
- Mr Furious Roy Orson Ticking time bomb
40
- of fury
41
-
42
- The I<Bowler> Carol Pinnsler Haunted bowling ball
43
-
44
- =end table
45
- =end pod
46
- `}
47
- </Podlite>,
48
- ),
49
- ).toMatchInlineSnapshot(`
50
- <div id="id">
51
- <div id="id">
52
- <p>
53
- test
54
- sdsdsd
55
- </p>
56
- </div>
57
- <h1 id="id">
58
- Test
59
- </h1>
60
- <table id="id">
61
- <caption class="caption">
62
- Super table!
63
- </caption>
64
- <tbody>
65
- <tr id="id">
66
- <th id="id">
67
- Superhero
68
- </th>
69
- <th id="id">
70
- Secret Identity
71
- </th>
72
- <th id="id">
73
- Superpower
74
- </th>
75
- </tr>
76
- <tr id="id">
77
- <td id="id">
78
- The Shoveller
79
- </td>
80
- <td id="id">
81
- Eddie Stevens
82
- </td>
83
- <td id="id">
84
- King Arthur&#x27;s singing shovel
85
- </td>
86
- </tr>
87
- <tr id="id">
88
- <td id="id">
89
- Blue Raja
90
- </td>
91
- <td id="id">
92
- Geoffrey Smith
93
- </td>
94
- <td id="id">
95
- Master of cutlery
96
- </td>
97
- </tr>
98
- <tr id="id">
99
- <td id="id">
100
- Mr Furious
101
- </td>
102
- <td id="id">
103
- Roy Orson
104
- </td>
105
- <td id="id">
106
- Ticking time bomb of fury
107
- </td>
108
- </tr>
109
- <tr id="id">
110
- <td id="id">
111
- The
112
- <i>
113
- Bowler
114
- </i>
115
- </td>
116
- <td id="id">
117
- Carol Pinnsler
118
- </td>
119
- <td id="id">
120
- Haunted bowling ball
121
- </td>
122
- </tr>
123
- </tbody>
124
- </table>
125
- </div>
126
- `)
127
- })
128
-
129
- it('accepts =alias', () => {
130
- expect(
131
- render(
132
- <Podlite>
133
- {`
134
- =begin pod
135
- =alias TEST 4D Kingdoms
136
- A<TEST>
137
- =end pod
138
- `}
139
- </Podlite>,
140
- ),
141
- ).toMatchInlineSnapshot(`
142
- <div id="id">
143
- <p>
144
- 4D Kingdoms
145
- </p>
146
- </div>
147
- `)
148
- })
149
-
150
- it('accepts =code', () => {
151
- render(
152
- <Podlite>
153
- {`
154
- =code
155
- sdkljsalkdjlsd
156
- asdasdasdasdsad
157
- =for code
158
- sdkljsalkdjlsd
159
- asdasdasdasdsad
160
- =begin code
161
- sdkljsalkdjlsd
162
- asdasdasdasdsad
163
- =end code
164
- `}
165
- </Podlite>,
166
- )
167
- expect(root.innerHTML).toMatchInlineSnapshot(`
168
- <code>
169
- <pre>
170
- sdkljsalkdjlsd
171
- asdasdasdasdsad
172
- </pre>
173
- </code>
174
- <code>
175
- <pre>
176
- sdkljsalkdjlsd
177
- asdasdasdasdsad
178
- </pre>
179
- </code>
180
- <code>
181
- <pre>
182
- sdkljsalkdjlsd
183
- asdasdasdasdsad
184
- </pre>
185
- </code>
186
- `)
187
- })
188
-
189
- it('accepts D<>', () => {
190
- render(
191
- <Podlite>
192
- {`
193
- =para
194
- A D<formatting code|formatting codes;formatters> provides a way
195
- to add inline mark-up to a D<piece> of text.
196
- `}
197
- </Podlite>,
198
- )
199
- expect(root.innerHTML).toMatchInlineSnapshot(`
200
- <div id="id">
201
- <p>
202
- A
203
- <dfn>
204
- formatting code
205
- </dfn>
206
- provides a way
207
- to add inline mark-up to a
208
- <dfn>
209
- piece
210
- </dfn>
211
- of text.
212
- </p>
213
- </div>
214
- `)
215
- })
216
-
217
- it('accepts L<>', () => {
218
- render(
219
- <Podlite>
220
- {`
221
- L<https://www.python.org/dev/peps/pep-0001/#what-is-a-pep>
222
- L<Test|https://example.com>
223
- `}
224
- </Podlite>,
225
- )
226
- expect(root.innerHTML).toMatchInlineSnapshot(`
227
- <p>
228
- <a href="https://www.python.org/dev/peps/pep-0001/#what-is-a-pep">
229
- https://www.python.org/dev/peps/pep-0001/#what-is-a-pep
230
- </a>
231
- <a href="https://example.com">
232
- Test
233
- </a>
234
- </p>
235
- `)
236
- })
237
-
238
- it('accepts =comment, Z<>, ', () => {
239
- render(
240
- <Podlite>
241
- {`
242
- =begin pod
243
- Z<comment>
244
- =comment Test
245
- =end pod
246
- `}
247
- </Podlite>,
248
- )
249
- expect(root.innerHTML).toMatchInlineSnapshot(`
250
- <div id="id">
251
- <p>
252
- </p>
253
- </div>
254
- `)
255
- })
256
-
257
- it('accepts E<>, R<>, V<>', () => {
258
- render(
259
- <Podlite>
260
- {`
261
- =begin pod
262
- The basic C<ln> command is: C<ln> B<R<source_file> R<target_file>>
263
- E<0d171; 0o253; 0b10101011; 0xAB>
264
- V<C<boo> B<bar> asd>
265
- =end pod
266
- `}
267
- </Podlite>,
268
- )
269
-
270
- expect(root.innerHTML).toMatchInlineSnapshot(`
271
- <div id="id">
272
- <p>
273
- The basic
274
- <code>
275
- ln
276
- </code>
277
- command is:
278
- <code>
279
- ln
280
- </code>
281
- <strong>
282
- <var>
283
- source_file
284
- </var>
285
- <var>
286
- target_file
287
- </var>
288
- </strong>
289
- ««««
290
- C&lt;boo&gt; B&lt;bar&gt; asd
291
- </p>
292
- </div>
293
- `)
294
- })
295
-
296
- it('accepts =output', () => {
297
- render(
298
- <Podlite>
299
- {`
300
- =for code :allow(T)
301
- T<output>
302
- =begin output
303
- Print? B<K<n>>
304
- =end output
305
- =for input
306
- Name: R<your surname>
307
- `}
308
- </Podlite>,
309
- )
310
- expect(root.innerHTML).toMatchInlineSnapshot(`
311
- <code>
312
- <pre>
313
- <samp>
314
- output
315
- </samp>
316
- </pre>
317
- </code>
318
- <pre>
319
- <samp>
320
- Print?
321
- <strong>
322
- <kbd>
323
- n
324
- </kbd>
325
- </strong>
326
- </samp>
327
- </pre>
328
- <pre>
329
- <kbd>
330
- Name:
331
- <var>
332
- your surname
333
- </var>
334
- </kbd>
335
- </pre>
336
- `)
337
- })
338
-
339
- it('accepts N<>', () => {
340
- render(
341
- <Podlite>
342
- {`
343
- =begin pod
344
- =para
345
- Use a C<for> loop instead.N<The Raku C<for> loop is far more
346
- powerful than its Perl 5 predecessor.> Preferably with an explicit
347
- iterator variable.
348
-
349
- =end pod
350
- `}
351
- </Podlite>,
352
- )
353
- expect(root.innerHTML).toMatchInlineSnapshot(`
354
- <div id="id">
355
- <div id="id">
356
- <p>
357
- Use a
358
- <code>
359
- for
360
- </code>
361
- loop instead.
362
- <sup id="fnref:1"
363
- class="footnote"
364
- >
365
- <a href="#fn:1">
366
- [1]
367
- </a>
368
- </sup>
369
- Preferably with an explicit
370
- iterator variable.
371
- </p>
372
- </div>
373
- </div>
374
- <p>
375
- </p>
376
- <div class="footnotes">
377
- <p>
378
- <sup id="fn:1"
379
- class="footnote"
380
- >
381
- <a href="#fnref:1">
382
- [1]
383
- </a>
384
- </sup>
385
- The Raku
386
- <code>
387
- for
388
- </code>
389
- loop is far more
390
- powerful than its Perl 5 predecessor.
391
- </p>
392
- </div>
393
- `)
394
- })
395
-
396
- it('accepts U<>, X<>, S<>', () => {
397
- render(
398
- <Podlite>
399
- {`
400
- =para
401
- An X<array|arrays> is an ordered list.
402
- U<a>. S<
403
- >
404
- `}
405
- </Podlite>,
406
- )
407
-
408
- expect(root.innerHTML).toMatchInlineSnapshot(`
409
- <div id="id">
410
- <p>
411
- An array is an ordered list.
412
- <u>
413
- a
414
- </u>
415
- .
416
- <br>
417
-    
418
- </p>
419
- </div>
420
- `)
421
- })
422
-
423
- it('accepts =Image base', () => {
424
- render(
425
- <Podlite>
426
- {`
427
- =begin pod
428
- =for Image :id<1> :caption<A picture of a cat> :link<https://example.com/cat.jpg>
429
- alternative https://www.example.org
430
- =end pod
431
- `}
432
- </Podlite>,
433
- )
434
- expect(root.innerHTML).toMatchInlineSnapshot(`
435
- <div id="id">
436
- <div class="image_block"
437
- id="1"
438
- >
439
- <a href="https://example.com/cat.jpg">
440
- <img src="https://www.example.org"
441
- alt="alternative"
442
- >
443
- </a>
444
- <div class="caption">
445
- <p>
446
- A picture of a cat
447
- </p>
448
- </div>
449
- </div>
450
- </div>
451
- `)
452
- })
453
-
454
- it('accepts =Image empty caption', () => {
455
- render(
456
- <Podlite>
457
- {`
458
- =begin pod
459
- =for Image :id<1> :link<https://example.com/cat.jpg>
460
- alternative https://www.example.org
461
- =end pod
462
- `}
463
- </Podlite>,
464
- )
465
- // console.log(root.innerHTML);return;
466
- expect(root.innerHTML).toMatchInlineSnapshot(`
467
- <div id="id">
468
- <div class="image_block"
469
- id="1"
470
- >
471
- <a href="https://example.com/cat.jpg">
472
- <img src="https://www.example.org"
473
- alt="alternative"
474
- >
475
- </a>
476
- </div>
477
- </div>
478
- <p>
479
- </p>
480
- `)
481
- })
482
-
483
- it('accepts =Image with fullset of attributes', () => {
484
- render(
485
- <Podlite>
486
- {`
487
- =begin pod
488
- =for Image :alt<alternative>
489
- = :link<'https://www.example.org'>
490
- = :src<'https://www.example.org'>
491
- = :caption<'caption'>
492
- = :id<'id'>
493
- content ignored
494
- =end pod
495
- `}
496
- </Podlite>,
497
- )
498
- expect(root.innerHTML).toMatchInlineSnapshot(`
499
- <div id="id">
500
- <div class="image_block"
501
- id="id"
502
- >
503
- <a href="https://www.example.org">
504
- <img src="https://www.example.org"
505
- alt="alternative"
506
- >
507
- </a>
508
- <div class="caption">
509
- <p>
510
- caption
511
- </p>
512
- </div>
513
- </div>
514
- </div>
515
- <p>
516
- </p>
517
- `)
518
- })
519
- it('accepts =TITLE', () => {
520
- render(
521
- <Podlite>
522
- {`
523
- =begin pod
524
- =TITLE test
525
- =para 1
526
- =end pod`}
527
- </Podlite>,
528
- )
529
- expect(root.innerHTML).toMatchInlineSnapshot(`
530
- <div id="id">
531
- <div>
532
- <h1 class="TITLE">
533
- TITLE
534
- </h1>
535
- <p>
536
- test
537
- </p>
538
- </div>
539
- <div id="id">
540
- <p>
541
- 1
542
- </p>
543
- </div>
544
- </div>
545
- `)
546
- })
547
-
548
- it('accepts =defn', () => {
549
- render(
550
- <Podlite>
551
- {`
552
- =defn MAD
553
- Affected with a high degree of intellectual independence.
554
- =defn MEEKNESS
555
- Uncommon patience in planning a revenge that is worth while.
556
- =defn
557
- MORAL
558
- Conforming to a local and mutable standard of right.
559
- Having the quality of general expediency.
560
- `}
561
- </Podlite>,
562
- )
563
- expect(root.innerHTML).toMatchInlineSnapshot(`
564
- <dl>
565
- <dt>
566
- MAD
567
- </dt>
568
- <dd>
569
- Affected with a high degree of intellectual independence.
570
- </dd>
571
- <dt>
572
- MEEKNESS
573
- </dt>
574
- <dd>
575
- Uncommon patience in planning a revenge that is worth while.
576
- </dd>
577
- <dt>
578
- MORAL
579
- </dt>
580
- <dd>
581
- Conforming to a local and mutable standard of right.
582
- Having the quality of general expediency.
583
- </dd>
584
- </dl>
585
- `)
586
- })
587
-
588
- it('accepts =nested', () => {
589
- render(
590
- <Podlite>
591
- {`
592
- =begin nested
593
- We are all of us in the gutter,B<NL>
594
- but some of us are looking at the stars!
595
- =begin nested
596
- -- Oscar Wilde
597
- =end nested
598
- =end nested
599
- `}
600
- </Podlite>,
601
- )
602
- expect(root.innerHTML).toMatchInlineSnapshot(`
603
- <blockquote>
604
- <p>
605
- We are all of us in the gutter,
606
- <strong>
607
- NL
608
- </strong>
609
- but some of us are looking at the stars!
610
- </p>
611
- <blockquote>
612
- <p>
613
- -- Oscar Wilde
614
- </p>
615
- </blockquote>
616
- </blockquote>
617
- `)
618
- })
619
-
620
- it('accepts =Toc', () => {
621
- render(
622
- <Podlite>
623
- {`
624
- =begin pod
625
- =Toc head1 item
626
- =for head1 :id<Test>
627
- head1
628
- =for item1 :id<item>
629
- item1
630
- =end pod
631
- `}
632
- </Podlite>,
633
- )
634
- expect(root.innerHTML).toMatchInlineSnapshot(`
635
- <div id="id">
636
- <div class="toc">
637
- <ul class="toc-list listlevel1">
638
- <li class="toc-item">
639
- <a href="#Test">
640
- head1
641
- </a>
642
- </li>
643
- <ul class="toc-list listlevel2">
644
- <li class="toc-item">
645
- <a href="#item">
646
- item1
647
- </a>
648
- </li>
649
- </ul>
650
- </ul>
651
- </div>
652
- <h1 id="Test">
653
- head1
654
- </h1>
655
- <ul>
656
- <li id="item">
657
- <p>
658
- item1
659
- </p>
660
- </li>
661
- </ul>
662
- </div>
663
- <p>
664
- </p>
665
- `)
666
- })
667
-
668
- it('id for headers', () => {
669
- render(
670
- <PodliteRaw>{`
671
- =head1 Test
672
- `}</PodliteRaw>,
673
- )
674
- expect(root.innerHTML).toMatchInlineSnapshot(`
675
- <h1 id="Test">
676
- Test
677
- </h1>
678
- `)
679
- })
680
-
681
- it.skip('accepts =Diagram', () => {
682
- render(
683
- <Podlite>
684
- {`
685
- =begin pod
686
- =Diagram
687
- graph LR
688
- A --- B
689
- B-->C[fa:fa-ban forbidden]
690
- B-->D(fa:fa-spinner aaaaa);
691
- =end pod
692
- `}
693
- </Podlite>,
694
- )
695
- console.log(root.innerHTML)
696
- // expect(root.innerHTML).toMatchInlineSnapshot();
697
- })
698
-
699
- it.skip('accepts =alias', () => {
700
- render(
701
- <Podlite>
702
- {`
703
- =begin pod
704
- =alias PROGNAME Earl Irradiatem Evermore
705
- =alias VENDOR 4D Kingdoms
706
- =alias TERMS_URLS =item L<http://www.4dk.com/eie>
707
- = =item L<http://www.4dk.co.uk/eie.io/>
708
- = =item L<http://www.fordecay.ch/canttouchthis>
709
- The use of A<PROGNAME> is subject to the terms and conditions
710
- laid out by A<VENDOR>, as specified at:
711
-
712
- A<TERMS_URLS>
713
-
714
- =end pod
715
- `}
716
- </Podlite>,
717
- )
718
- console.log(root.innerHTML)
719
- // expect(root.innerHTML).toMatchInlineSnapshot();
720
- })