@podlite/to-jsx 0.0.16 → 0.0.17

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,30 +1,12 @@
1
1
  import Podlite from '../src/index'
2
2
  import React from 'react'
3
- import ReactDOM from 'react-dom'
3
+ import { renderToStaticMarkup } from 'react-dom/server'
4
4
 
5
5
  const fs = require('fs')
6
6
  const path = require('path')
7
- const glob = require('glob')
7
+ const glob = require('glob')
8
8
 
9
-
10
- // const describe = ( _ , f)=> f()
11
- // const it = (_, f) => f()
12
- // const expect = (any):any=>{
13
- // const c=(any):any=>{}
14
- // c.toEqual = ()=>{}
15
- // return c
16
- // }
17
-
18
- const root = document.body.appendChild(document.createElement('div'))
19
-
20
- function render(jsx) {
21
- return ReactDOM.render(jsx, root)
22
- }
23
-
24
- afterEach(() => ReactDOM.unmountComponentAtNode(root))
25
-
26
-
27
- // load examples from fixtures src
9
+ // load examples from fixtures src
28
10
  /**
29
11
  *
30
12
  * @returns
@@ -34,33 +16,32 @@ afterEach(() => ReactDOM.unmountComponentAtNode(root))
34
16
  testFile: 't/fixtures/00-maintests_5.txt' }, 
35
17
  */
36
18
  const allSrcFixtures = () => {
37
- const pathToTests = path.resolve(__dirname, './fixtures-src')
38
- const files = glob.sync(`${pathToTests}/*.t`)
39
- const loaded = files.map( file => {
40
- const d = fs.readFileSync(file)
41
- const s = `${d}`.split(/#---+\n/)
42
- .filter( t => t.match(/^\s*=/))
43
- .map( (text,i) => {
44
- const { dir, name } = path.parse(file)
45
- const testFile = `t/fixtures/${name}_${i}.txt`
46
- return {file,
47
- id:i,
48
- text,
49
- testFile,
50
- }});
51
- return s
52
- }
53
- ).flat()
54
- return loaded
19
+ const pathToTests = path.resolve(__dirname, './fixtures-src')
20
+ const files = glob.sync(`${pathToTests}/*.t`)
21
+ const loaded = files
22
+ .map(file => {
23
+ const d = fs.readFileSync(file)
24
+ const s = `${d}`
25
+ .split(/#---+\n/)
26
+ .filter(t => t.match(/^\s*=/))
27
+ .map((text, i) => {
28
+ const { dir, name } = path.parse(file)
29
+ const testFile = `t/fixtures/${name}_${i}.txt`
30
+ return { file, id: i, text, testFile }
31
+ })
32
+ return s
33
+ })
34
+ .flat()
35
+ return loaded
55
36
  }
56
37
  const t = allSrcFixtures()
57
38
  t
58
39
 
59
- describe("run parser tests", () => {
60
- allSrcFixtures().map(i => test(i.file, ()=>{
61
- render(<Podlite>{i.text}</Podlite>)
62
- // console.log(root.innerHTML)
63
- expect(root.innerHTML).not.toBeNull()
64
- }
65
- ))
40
+ describe('run parser tests', () => {
41
+ allSrcFixtures().map(i =>
42
+ test(i.file, () => {
43
+ const result = renderToStaticMarkup(<Podlite>{i.text}</Podlite>)
44
+ expect(result).not.toBeNull()
45
+ }),
46
+ )
66
47
  })
@@ -1,29 +1,28 @@
1
- import { TestPodlite as Podlite, Podlite as PodliteRaw } from '../src/index';
2
- import React from 'react';
3
- import ReactDOM from 'react-dom';
4
-
5
- const root = document.body.appendChild(document.createElement('div'));
1
+ import { TestPodlite as Podlite, Podlite as PodliteRaw } from '../src/index'
2
+ import React from 'react'
3
+ import { renderToStaticMarkup } from 'react-dom/server'
6
4
 
5
+ const root = { innerHTML: '' }
7
6
  function render(jsx) {
8
- return ReactDOM.render(jsx, root);
7
+ root.innerHTML = renderToStaticMarkup(jsx)
8
+ return root.innerHTML
9
9
  }
10
10
 
11
- afterEach(() => ReactDOM.unmountComponentAtNode(root));
12
-
13
11
  it('para content', () => {
14
- render(<Podlite>Hello!</Podlite>);
12
+ render(<Podlite>Hello!</Podlite>)
15
13
 
16
14
  expect(root.innerHTML).toMatchInlineSnapshot(`
17
15
  <p>
18
16
  Hello!
19
17
  </p>
20
- `);
21
- });
18
+ `)
19
+ })
22
20
 
23
21
  it('table', () => {
24
- render(
25
- <Podlite>
26
- {`
22
+ expect(
23
+ render(
24
+ <Podlite>
25
+ {`
27
26
  =begin pod
28
27
  =para test
29
28
  sdsdsd
@@ -45,9 +44,9 @@ sdsdsd
45
44
  =end table
46
45
  =end pod
47
46
  `}
48
- </Podlite>,
49
- );
50
- expect(root.innerHTML).toMatchInlineSnapshot(`
47
+ </Podlite>,
48
+ ),
49
+ ).toMatchInlineSnapshot(`
51
50
  <div id="id">
52
51
  <div id="id">
53
52
  <p>
@@ -82,7 +81,7 @@ sdsdsd
82
81
  Eddie Stevens
83
82
  </td>
84
83
  <td id="id">
85
- King Arthur's singing shovel
84
+ King Arthur&#x27;s singing shovel
86
85
  </td>
87
86
  </tr>
88
87
  <tr id="id">
@@ -124,28 +123,29 @@ sdsdsd
124
123
  </tbody>
125
124
  </table>
126
125
  </div>
127
- `);
128
- });
126
+ `)
127
+ })
129
128
 
130
129
  it('accepts =alias', () => {
131
- render(
132
- <Podlite>
133
- {`
130
+ expect(
131
+ render(
132
+ <Podlite>
133
+ {`
134
134
  =begin pod
135
135
  =alias TEST 4D Kingdoms
136
136
  A<TEST>
137
137
  =end pod
138
138
  `}
139
- </Podlite>,
140
- );
141
- expect(root.innerHTML).toMatchInlineSnapshot(`
139
+ </Podlite>,
140
+ ),
141
+ ).toMatchInlineSnapshot(`
142
142
  <div id="id">
143
143
  <p>
144
144
  4D Kingdoms
145
145
  </p>
146
146
  </div>
147
- `);
148
- });
147
+ `)
148
+ })
149
149
 
150
150
  it('accepts =code', () => {
151
151
  render(
@@ -163,7 +163,7 @@ it('accepts =code', () => {
163
163
  =end code
164
164
  `}
165
165
  </Podlite>,
166
- );
166
+ )
167
167
  expect(root.innerHTML).toMatchInlineSnapshot(`
168
168
  <code>
169
169
  <pre>
@@ -183,8 +183,8 @@ it('accepts =code', () => {
183
183
  asdasdasdasdsad
184
184
  </pre>
185
185
  </code>
186
- `);
187
- });
186
+ `)
187
+ })
188
188
 
189
189
  it('accepts D<>', () => {
190
190
  render(
@@ -195,7 +195,7 @@ it('accepts D<>', () => {
195
195
  to add inline mark-up to a D<piece> of text.
196
196
  `}
197
197
  </Podlite>,
198
- );
198
+ )
199
199
  expect(root.innerHTML).toMatchInlineSnapshot(`
200
200
  <div id="id">
201
201
  <p>
@@ -211,8 +211,8 @@ it('accepts D<>', () => {
211
211
  of text.
212
212
  </p>
213
213
  </div>
214
- `);
215
- });
214
+ `)
215
+ })
216
216
 
217
217
  it('accepts L<>', () => {
218
218
  render(
@@ -222,7 +222,7 @@ L<https://www.python.org/dev/peps/pep-0001/#what-is-a-pep>
222
222
  L<Test|https://example.com>
223
223
  `}
224
224
  </Podlite>,
225
- );
225
+ )
226
226
  expect(root.innerHTML).toMatchInlineSnapshot(`
227
227
  <p>
228
228
  <a href="https://www.python.org/dev/peps/pep-0001/#what-is-a-pep">
@@ -232,8 +232,8 @@ L<Test|https://example.com>
232
232
  Test
233
233
  </a>
234
234
  </p>
235
- `);
236
- });
235
+ `)
236
+ })
237
237
 
238
238
  it('accepts =comment, Z<>, ', () => {
239
239
  render(
@@ -245,14 +245,14 @@ Z<comment>
245
245
  =end pod
246
246
  `}
247
247
  </Podlite>,
248
- );
248
+ )
249
249
  expect(root.innerHTML).toMatchInlineSnapshot(`
250
250
  <div id="id">
251
251
  <p>
252
252
  </p>
253
253
  </div>
254
- `);
255
- });
254
+ `)
255
+ })
256
256
 
257
257
  it('accepts E<>, R<>, V<>', () => {
258
258
  render(
@@ -265,7 +265,7 @@ V<C<boo> B<bar> asd>
265
265
  =end pod
266
266
  `}
267
267
  </Podlite>,
268
- );
268
+ )
269
269
 
270
270
  expect(root.innerHTML).toMatchInlineSnapshot(`
271
271
  <div id="id">
@@ -290,8 +290,8 @@ V<C<boo> B<bar> asd>
290
290
  C&lt;boo&gt; B&lt;bar&gt; asd
291
291
  </p>
292
292
  </div>
293
- `);
294
- });
293
+ `)
294
+ })
295
295
 
296
296
  it('accepts =output', () => {
297
297
  render(
@@ -306,7 +306,7 @@ Print? B<K<n>>
306
306
  Name: R<your surname>
307
307
  `}
308
308
  </Podlite>,
309
- );
309
+ )
310
310
  expect(root.innerHTML).toMatchInlineSnapshot(`
311
311
  <code>
312
312
  <pre>
@@ -333,8 +333,8 @@ Print? B<K<n>>
333
333
  </var>
334
334
  </kbd>
335
335
  </pre>
336
- `);
337
- });
336
+ `)
337
+ })
338
338
 
339
339
  it('accepts N<>', () => {
340
340
  render(
@@ -349,7 +349,7 @@ it('accepts N<>', () => {
349
349
  =end pod
350
350
  `}
351
351
  </Podlite>,
352
- );
352
+ )
353
353
  expect(root.innerHTML).toMatchInlineSnapshot(`
354
354
  <div id="id">
355
355
  <div id="id">
@@ -390,8 +390,8 @@ it('accepts N<>', () => {
390
390
  powerful than its Perl 5 predecessor.
391
391
  </p>
392
392
  </div>
393
- `);
394
- });
393
+ `)
394
+ })
395
395
 
396
396
  it('accepts U<>, X<>, S<>', () => {
397
397
  render(
@@ -403,7 +403,7 @@ it('accepts U<>, X<>, S<>', () => {
403
403
  >
404
404
  `}
405
405
  </Podlite>,
406
- );
406
+ )
407
407
 
408
408
  expect(root.innerHTML).toMatchInlineSnapshot(`
409
409
  <div id="id">
@@ -414,11 +414,11 @@ it('accepts U<>, X<>, S<>', () => {
414
414
  </u>
415
415
  .
416
416
  <br>
417
- &nbsp;&nbsp;&nbsp;
417
+    
418
418
  </p>
419
419
  </div>
420
- `);
421
- });
420
+ `)
421
+ })
422
422
 
423
423
  it('accepts =Image base', () => {
424
424
  render(
@@ -430,7 +430,7 @@ it('accepts =Image base', () => {
430
430
  =end pod
431
431
  `}
432
432
  </Podlite>,
433
- );
433
+ )
434
434
  expect(root.innerHTML).toMatchInlineSnapshot(`
435
435
  <div id="id">
436
436
  <div class="image_block"
@@ -448,8 +448,8 @@ it('accepts =Image base', () => {
448
448
  </div>
449
449
  </div>
450
450
  </div>
451
- `);
452
- });
451
+ `)
452
+ })
453
453
 
454
454
  it('accepts =Image empty caption', () => {
455
455
  render(
@@ -461,7 +461,7 @@ it('accepts =Image empty caption', () => {
461
461
  =end pod
462
462
  `}
463
463
  </Podlite>,
464
- );
464
+ )
465
465
  // console.log(root.innerHTML);return;
466
466
  expect(root.innerHTML).toMatchInlineSnapshot(`
467
467
  <div id="id">
@@ -477,8 +477,8 @@ it('accepts =Image empty caption', () => {
477
477
  </div>
478
478
  <p>
479
479
  </p>
480
- `);
481
- });
480
+ `)
481
+ })
482
482
 
483
483
  it('accepts =Image with fullset of attributes', () => {
484
484
  render(
@@ -494,7 +494,7 @@ content ignored
494
494
  =end pod
495
495
  `}
496
496
  </Podlite>,
497
- );
497
+ )
498
498
  expect(root.innerHTML).toMatchInlineSnapshot(`
499
499
  <div id="id">
500
500
  <div class="image_block"
@@ -514,8 +514,8 @@ content ignored
514
514
  </div>
515
515
  <p>
516
516
  </p>
517
- `);
518
- });
517
+ `)
518
+ })
519
519
  it('accepts =TITLE', () => {
520
520
  render(
521
521
  <Podlite>
@@ -525,7 +525,7 @@ it('accepts =TITLE', () => {
525
525
  =para 1
526
526
  =end pod`}
527
527
  </Podlite>,
528
- );
528
+ )
529
529
  expect(root.innerHTML).toMatchInlineSnapshot(`
530
530
  <div id="id">
531
531
  <div>
@@ -542,8 +542,8 @@ it('accepts =TITLE', () => {
542
542
  </p>
543
543
  </div>
544
544
  </div>
545
- `);
546
- });
545
+ `)
546
+ })
547
547
 
548
548
  it('accepts =defn', () => {
549
549
  render(
@@ -559,7 +559,7 @@ Conforming to a local and mutable standard of right.
559
559
  Having the quality of general expediency.
560
560
  `}
561
561
  </Podlite>,
562
- );
562
+ )
563
563
  expect(root.innerHTML).toMatchInlineSnapshot(`
564
564
  <dl>
565
565
  <dt>
@@ -582,8 +582,8 @@ Having the quality of general expediency.
582
582
  Having the quality of general expediency.
583
583
  </dd>
584
584
  </dl>
585
- `);
586
- });
585
+ `)
586
+ })
587
587
 
588
588
  it('accepts =nested', () => {
589
589
  render(
@@ -598,7 +598,7 @@ but some of us are looking at the stars!
598
598
  =end nested
599
599
  `}
600
600
  </Podlite>,
601
- );
601
+ )
602
602
  expect(root.innerHTML).toMatchInlineSnapshot(`
603
603
  <blockquote>
604
604
  <p>
@@ -614,8 +614,8 @@ but some of us are looking at the stars!
614
614
  </p>
615
615
  </blockquote>
616
616
  </blockquote>
617
- `);
618
- });
617
+ `)
618
+ })
619
619
 
620
620
  it('accepts =Toc', () => {
621
621
  render(
@@ -630,7 +630,7 @@ it('accepts =Toc', () => {
630
630
  =end pod
631
631
  `}
632
632
  </Podlite>,
633
- );
633
+ )
634
634
  expect(root.innerHTML).toMatchInlineSnapshot(`
635
635
  <div id="id">
636
636
  <div class="toc">
@@ -662,21 +662,21 @@ it('accepts =Toc', () => {
662
662
  </div>
663
663
  <p>
664
664
  </p>
665
- `);
666
- });
665
+ `)
666
+ })
667
667
 
668
668
  it('id for headers', () => {
669
669
  render(
670
670
  <PodliteRaw>{`
671
671
  =head1 Test
672
672
  `}</PodliteRaw>,
673
- );
673
+ )
674
674
  expect(root.innerHTML).toMatchInlineSnapshot(`
675
675
  <h1 id="Test">
676
676
  Test
677
677
  </h1>
678
- `);
679
- });
678
+ `)
679
+ })
680
680
 
681
681
  it.skip('accepts =Diagram', () => {
682
682
  render(
@@ -691,10 +691,10 @@ B-->D(fa:fa-spinner aaaaa);
691
691
  =end pod
692
692
  `}
693
693
  </Podlite>,
694
- );
695
- console.log(root.innerHTML);
694
+ )
695
+ console.log(root.innerHTML)
696
696
  // expect(root.innerHTML).toMatchInlineSnapshot();
697
- });
697
+ })
698
698
 
699
699
  it.skip('accepts =alias', () => {
700
700
  render(
@@ -714,7 +714,7 @@ A<TERMS_URLS>
714
714
  =end pod
715
715
  `}
716
716
  </Podlite>,
717
- );
718
- console.log(root.innerHTML);
717
+ )
718
+ console.log(root.innerHTML)
719
719
  // expect(root.innerHTML).toMatchInlineSnapshot();
720
- });
720
+ })
package/tsconfig.json CHANGED
@@ -11,8 +11,10 @@
11
11
  "jsx": "react",
12
12
 
13
13
  "compilerOptions": {
14
- "target": "es2017",
15
- "module": "commonjs",
14
+ // "target": "es2017",
15
+ // "module": "commonjs",
16
+ "module": "esnext",
17
+ "target": "ESNext",
16
18
  "moduleResolution": "node",
17
19
  "sourceMap": true,
18
20
  "jsx": "react",
@@ -22,6 +24,8 @@
22
24
  "downlevelIteration": true,
23
25
  "declaration": true,
24
26
  "incremental": true,
27
+ "esModuleInterop":true,
28
+ "composite": true
25
29
  },
26
30
  "references": [
27
31
  {