@podlite/markdown 0.0.5 → 0.0.6

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 CHANGED
@@ -1,28 +1,25 @@
1
- import { isValidateError } from "@podlite/schema";
2
- import { validateAstTree } from "@podlite/schema";
3
- import { validateAst } from "@podlite/schema";
4
- import { frozenIds } from "podlite/src";
5
- import { md2ast } from "../src/tools";
6
- import { podlite as podlite_core } from "podlite";
7
- import { PodliteDocument } from "@podlite/schema";
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'
8
5
 
9
- const process = (src) => {
10
- return frozenIds()(md2ast(src));
11
- };
6
+ const process = src => {
7
+ return frozenIds()(md2ast(src))
8
+ }
12
9
 
13
10
  export const parse = (str: string): PodliteDocument => {
14
- let podlite = podlite_core({ importPlugins: false }).use({});
15
- let tree = podlite.parse(str);
16
- const asAst = podlite.toAstResult(tree);
17
- return asAst.interator;
18
- };
19
- it("=Markdown: parse para", () => {
20
- const pod = `text`;
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`
21
18
  // const tree1 = parse(pod);
22
- const tree = process(pod);
23
- const r = validateAstTree([tree]);
24
- expect(r).toEqual([]);
25
- const errorDescribe = isValidateError(r, tree);
19
+ const tree = process(pod)
20
+ const r = validateAstTree([tree])
21
+ expect(r).toEqual([])
22
+ const errorDescribe = isValidateError(r, tree)
26
23
  expect(process(pod)).toMatchInlineSnapshot(`
27
24
  Object {
28
25
  "content": Array [
@@ -53,29 +50,29 @@ it("=Markdown: parse para", () => {
53
50
  "name": "root",
54
51
  "type": "block",
55
52
  }
56
- `);
57
- });
53
+ `)
54
+ })
58
55
 
59
- it.skip("[markdown]: parse para", () => {
60
- const pod = `text`;
61
- const tree = process(pod);
56
+ it.skip('[markdown]: parse para', () => {
57
+ const pod = `text`
58
+ const tree = process(pod)
62
59
  // console.log(JSON.stringify(tree, null, 2));
63
60
  // console.log(JSON.stringify(parse(`L<https://uerl>`), null, 2));
64
- const r = validateAstTree([tree]);
65
- expect(r).toEqual([]);
66
- const errorDescribe = isValidateError(r, tree);
61
+ const r = validateAstTree([tree])
62
+ expect(r).toEqual([])
63
+ const errorDescribe = isValidateError(r, tree)
67
64
  // expect(process(pod)).toMatchInlineSnapshot();
68
- });
65
+ })
69
66
 
70
- it("[markdown]: parse headers", () => {
67
+ it('[markdown]: parse headers', () => {
71
68
  const pod = `## build
72
69
 
73
70
  Generate JavaScript documentation as a list of parsed JSDoc
74
- comments, given a root file as a path`;
75
- const tree = process(pod);
76
- const r = validateAstTree([tree]);
77
- expect(r).toEqual([]);
78
- const errorDescribe = isValidateError(r, tree);
71
+ comments, given a root file as a path`
72
+ const tree = process(pod)
73
+ const r = validateAstTree([tree])
74
+ expect(r).toEqual([])
75
+ const errorDescribe = isValidateError(r, tree)
79
76
  expect(process(pod)).toMatchInlineSnapshot(`
80
77
  Object {
81
78
  "content": Array [
@@ -129,14 +126,14 @@ comments, given a root file as a path`;
129
126
  "name": "root",
130
127
  "type": "block",
131
128
  }
132
- `);
133
- });
134
- it("[markdown]: parse link", () => {
135
- const pod = `[#raku IRC channel](https://raku.org/community/irc)`;
136
- const tree = process(pod);
137
- const r = validateAstTree([tree]);
138
- expect(r).toEqual([]);
139
- const errorDescribe = isValidateError(r, tree);
129
+ `)
130
+ })
131
+ it('[markdown]: parse link', () => {
132
+ const pod = `[#raku IRC channel](https://raku.org/community/irc)`
133
+ const tree = process(pod)
134
+ const r = validateAstTree([tree])
135
+ expect(r).toEqual([])
136
+ const errorDescribe = isValidateError(r, tree)
140
137
  expect(process(pod)).toMatchInlineSnapshot(`
141
138
  Object {
142
139
  "content": Array [
@@ -174,14 +171,14 @@ it("[markdown]: parse link", () => {
174
171
  "name": "root",
175
172
  "type": "block",
176
173
  }
177
- `);
178
- });
179
- it("[markdown]: parse image", () => {
180
- const pod = `![foo](/url "title")`;
181
- const tree = process(pod);
182
- const r = validateAstTree([tree]);
183
- expect(r).toEqual([]);
184
- const errorDescribe = isValidateError(r, tree);
174
+ `)
175
+ })
176
+ it('[markdown]: parse image', () => {
177
+ const pod = `![foo](/url "title")`
178
+ const tree = process(pod)
179
+ const r = validateAstTree([tree])
180
+ expect(r).toEqual([])
181
+ const errorDescribe = isValidateError(r, tree)
185
182
  expect(process(pod)).toMatchInlineSnapshot(`
186
183
  Object {
187
184
  "content": Array [
@@ -244,10 +241,10 @@ it("[markdown]: parse image", () => {
244
241
  "name": "root",
245
242
  "type": "block",
246
243
  }
247
- `);
248
- });
244
+ `)
245
+ })
249
246
 
250
- it("[markdown]: parse refs", () => {
247
+ it('[markdown]: parse refs', () => {
251
248
  const pod = `### Table of Contents
252
249
 
253
250
  - [lint][1]
@@ -256,11 +253,11 @@ it("[markdown]: parse refs", () => {
256
253
 
257
254
  [1]: #lint
258
255
 
259
- [2]: #parameters`;
260
- const tree = process(pod);
261
- const r = validateAstTree([tree]);
262
- expect(r).toEqual([]);
263
- const errorDescribe = isValidateError(r, tree);
256
+ [2]: #parameters`
257
+ const tree = process(pod)
258
+ const r = validateAstTree([tree])
259
+ expect(r).toEqual([])
260
+ const errorDescribe = isValidateError(r, tree)
264
261
  expect(process(pod)).toMatchInlineSnapshot(`
265
262
  Object {
266
263
  "content": Array [
@@ -408,19 +405,19 @@ it("[markdown]: parse refs", () => {
408
405
  "name": "root",
409
406
  "type": "block",
410
407
  }
411
- `);
412
- });
408
+ `)
409
+ })
413
410
 
414
- it("[markdown]: broken_refs", () => {
411
+ it('[markdown]: broken_refs', () => {
415
412
  const pod = `### Parameters
416
413
 
417
414
  - \`comments\` **[Array][17]&lt;[Object][19]>** parsed comments
418
415
  - \`args\` **[Object][19]** Options that can customize the output
419
- `;
420
- const tree = process(pod);
421
- const r = validateAstTree([tree]);
422
- expect(r).toEqual([]);
423
- const errorDescribe = isValidateError(r, tree);
416
+ `
417
+ const tree = process(pod)
418
+ const r = validateAstTree([tree])
419
+ expect(r).toEqual([])
420
+ const errorDescribe = isValidateError(r, tree)
424
421
  expect(process(pod)).toMatchInlineSnapshot(`
425
422
  Object {
426
423
  "content": Array [
@@ -575,19 +572,19 @@ it("[markdown]: broken_refs", () => {
575
572
  "name": "root",
576
573
  "type": "block",
577
574
  }
578
- `);
579
- });
575
+ `)
576
+ })
580
577
 
581
- it("[markdown]: parse code", () => {
578
+ it('[markdown]: parse code', () => {
582
579
  const pod = `
583
580
  \`\`\`javascript
584
581
  var documentation = require('documentation');
585
582
  \`\`\`
586
- `;
587
- const tree = process(pod);
588
- const r = validateAstTree([tree]);
589
- expect(r).toEqual([]);
590
- const errorDescribe = isValidateError(r, tree);
583
+ `
584
+ const tree = process(pod)
585
+ const r = validateAstTree([tree])
586
+ expect(r).toEqual([])
587
+ const errorDescribe = isValidateError(r, tree)
591
588
  expect(process(pod)).toMatchInlineSnapshot(`
592
589
  Object {
593
590
  "content": Array [
@@ -628,10 +625,10 @@ var documentation = require('documentation');
628
625
  "name": "root",
629
626
  "type": "block",
630
627
  }
631
- `);
632
- });
628
+ `)
629
+ })
633
630
 
634
- it("[markdown]: inline_code", () => {
631
+ it('[markdown]: inline_code', () => {
635
632
  const pod = `
636
633
  *This text will be italic*
637
634
  _This will also be italic_
@@ -640,11 +637,11 @@ _This will also be italic_
640
637
  __This will also be bold__
641
638
 
642
639
  _You **can** combine them_
643
- `;
644
- const tree = process(pod);
645
- const r = validateAstTree([tree]);
646
- expect(r).toEqual([]);
647
- const errorDescribe = isValidateError(r, tree);
640
+ `
641
+ const tree = process(pod)
642
+ const r = validateAstTree([tree])
643
+ expect(r).toEqual([])
644
+ const errorDescribe = isValidateError(r, tree)
648
645
  expect(process(pod)).toMatchInlineSnapshot(`
649
646
  Object {
650
647
  "content": Array [
@@ -761,18 +758,18 @@ _You **can** combine them_
761
758
  "name": "root",
762
759
  "type": "block",
763
760
  }
764
- `);
765
- });
761
+ `)
762
+ })
766
763
 
767
- it("[markdown]: thematic_break", () => {
764
+ it('[markdown]: thematic_break', () => {
768
765
  const pod = `
769
766
 
770
767
  ---
771
- `;
772
- const tree = process(pod);
773
- const r = validateAstTree([tree]);
774
- expect(r).toEqual([]);
775
- const errorDescribe = isValidateError(r, tree);
768
+ `
769
+ const tree = process(pod)
770
+ const r = validateAstTree([tree])
771
+ expect(r).toEqual([])
772
+ const errorDescribe = isValidateError(r, tree)
776
773
  expect(process(pod)).toMatchInlineSnapshot(`
777
774
  Object {
778
775
  "content": Array [],
@@ -781,20 +778,20 @@ it("[markdown]: thematic_break", () => {
781
778
  "name": "root",
782
779
  "type": "block",
783
780
  }
784
- `);
785
- });
781
+ `)
782
+ })
786
783
 
787
- it("[markdown]: blockquote", () => {
784
+ it('[markdown]: blockquote', () => {
788
785
  const pod = `
789
786
  As Kanye West said:
790
787
 
791
788
  > We're living the future so
792
789
  > the present is our past.
793
- `;
794
- const tree = process(pod);
795
- const r = validateAstTree([tree]);
796
- expect(r).toEqual([]);
797
- const errorDescribe = isValidateError(r, tree);
790
+ `
791
+ const tree = process(pod)
792
+ const r = validateAstTree([tree])
793
+ expect(r).toEqual([])
794
+ const errorDescribe = isValidateError(r, tree)
798
795
  expect(process(pod)).toMatchInlineSnapshot(`
799
796
  Object {
800
797
  "content": Array [
@@ -867,20 +864,20 @@ As Kanye West said:
867
864
  "name": "root",
868
865
  "type": "block",
869
866
  }
870
- `);
871
- });
867
+ `)
868
+ })
872
869
 
873
- it("[markdown]: parse table", () => {
870
+ it('[markdown]: parse table', () => {
874
871
  const pod = `
875
872
  First Header | Second Header
876
873
  ------------ | -------------
877
874
  Content from cell 1 | Content from cell 2
878
875
  Content in the first column | Content in the second column
879
- `;
880
- const tree = process(pod);
881
- const r = validateAstTree([tree]);
882
- expect(r).toEqual([]);
883
- const errorDescribe = isValidateError(r, tree);
876
+ `
877
+ const tree = process(pod)
878
+ const r = validateAstTree([tree])
879
+ expect(r).toEqual([])
880
+ const errorDescribe = isValidateError(r, tree)
884
881
  expect(process(pod)).toMatchInlineSnapshot(`
885
882
  Object {
886
883
  "content": Array [
@@ -1096,17 +1093,17 @@ Content in the first column | Content in the second column
1096
1093
  "name": "root",
1097
1094
  "type": "block",
1098
1095
  }
1099
- `);
1100
- });
1096
+ `)
1097
+ })
1101
1098
 
1102
- it("[markdown]: parse strikethrough", () => {
1099
+ it('[markdown]: parse strikethrough', () => {
1103
1100
  const pod = `
1104
1101
  ~~this~~
1105
- `;
1106
- const tree = process(pod);
1107
- const r = validateAstTree([tree]);
1108
- expect(r).toEqual([]);
1109
- const errorDescribe = isValidateError(r, tree);
1102
+ `
1103
+ const tree = process(pod)
1104
+ const r = validateAstTree([tree])
1105
+ expect(r).toEqual([])
1106
+ const errorDescribe = isValidateError(r, tree)
1110
1107
  expect(process(pod)).toMatchInlineSnapshot(`
1111
1108
  Object {
1112
1109
  "content": Array [
@@ -1143,10 +1140,10 @@ it("[markdown]: parse strikethrough", () => {
1143
1140
  "name": "root",
1144
1141
  "type": "block",
1145
1142
  }
1146
- `);
1147
- });
1148
- it("[markdown]: parse diagrams", () => {
1149
- const pod = `
1143
+ `)
1144
+ })
1145
+ it('[markdown]: parse diagrams', () => {
1146
+ const pod = `
1150
1147
  \`\`\`mermaids caption="1"
1151
1148
  graph TD;
1152
1149
  A-->B;
@@ -1154,7 +1151,7 @@ graph TD;
1154
1151
  B-->D;
1155
1152
  C-->D;
1156
1153
  \`\`\`
1157
- `;
1158
- const tree = process(pod);
1159
- // console.log(JSON.stringify(tree, null,2 ))
1154
+ `
1155
+ const tree = process(pod)
1156
+ // console.log(JSON.stringify(tree, null,2 ))
1160
1157
  })
package/t/plugin.test.tsx CHANGED
@@ -1,43 +1,34 @@
1
- import { PodliteDocument, validateAstTree } from "@podlite/schema";
2
- import { frozenIds, podlite as podlite_core } from "podlite";
3
- import { PluginRegister } from "../src";
4
- import React from "react";
5
- import ReactDOM from "react-dom";
6
- import { makeTestPodlite } from "@podlite/to-jsx";
1
+ import React from 'react'
2
+ import { PodliteDocument, frozenIds, podlitePluggable, validateAstTree } from '@podlite/schema'
3
+ import { PluginRegister } from '../src'
4
+ import { renderToStaticMarkup } from 'react-dom/server'
5
+ import { makeTestPodlite } from '@podlite/to-jsx'
7
6
 
8
7
  const Podlite = makeTestPodlite(
9
- podlite_core({ importPlugins: false }).use({
8
+ podlitePluggable().use({
10
9
  ...PluginRegister,
11
- })
12
- );
13
-
14
- const root = document.body.appendChild(document.createElement("div"));
15
-
16
- function render(jsx) {
17
- return ReactDOM.render(jsx, root);
18
- }
19
-
20
- afterEach(() => ReactDOM.unmountComponentAtNode(root));
10
+ }),
11
+ )
21
12
 
22
13
  export const parse = (str: string): PodliteDocument => {
23
- let podlite = podlite_core({ importPlugins: false }).use({
14
+ let podlite = podlitePluggable().use({
24
15
  ...PluginRegister,
25
- });
26
- let tree = podlite.parse(str);
27
- const asAst = podlite.toAstResult(tree);
28
- return frozenIds()(asAst.interator);
29
- };
16
+ })
17
+ let tree = podlite.parse(str)
18
+ const asAst = podlite.toAstResult(tree)
19
+ return frozenIds()(asAst.interator)
20
+ }
30
21
 
31
- it("=Markdown: check line offset", () => {
22
+ it('=Markdown: check line offset', () => {
32
23
  const pod = `
33
24
  =para test
34
25
  =Markdown
35
26
  header1
36
- `;
37
- const tree = parse(pod);
27
+ `
28
+ const tree = parse(pod)
38
29
  // console.log(JSON.stringify(tree, null, 2));
39
- const r = validateAstTree([tree]);
40
- expect(r).toEqual([]);
30
+ const r = validateAstTree([tree])
31
+ expect(r).toEqual([])
41
32
  expect(parse(pod)).toMatchInlineSnapshot(`
42
33
  Object {
43
34
  "content": Array [
@@ -143,10 +134,10 @@ header1
143
134
  "name": "root",
144
135
  "type": "block",
145
136
  }
146
- `);
147
- });
137
+ `)
138
+ })
148
139
 
149
- it("=Markdown: jsx", () => {
140
+ it('=Markdown: jsx', () => {
150
141
  const pod = `
151
142
  =para test
152
143
  =begin Markdown
@@ -154,9 +145,9 @@ it("=Markdown: jsx", () => {
154
145
  =head1 **ss**
155
146
  ddd
156
147
  =end Markdown
157
- `;
158
- render(<Podlite>{pod}</Podlite>);
159
- expect(root.innerHTML).toMatchInlineSnapshot(`
148
+ `
149
+ // render(<Podlite>{pod}</Podlite>);
150
+ expect(renderToStaticMarkup(<Podlite>{pod}</Podlite>)).toMatchInlineSnapshot(`
160
151
  <div id="id">
161
152
  <p>
162
153
  test
@@ -172,17 +163,17 @@ it("=Markdown: jsx", () => {
172
163
  </p>
173
164
  <p>
174
165
  </p>
175
- `);
176
- });
166
+ `)
167
+ })
177
168
 
178
169
  it("=Markdown: check 'delete' line element", () => {
179
170
  const pod = `
180
171
  =begin Markdown
181
172
  asd ~~asdsd~~
182
173
  =end Markdown
183
- `;
184
- render(<Podlite>{pod}</Podlite>);
185
- expect(root.innerHTML).toMatchInlineSnapshot(`
174
+ `
175
+ // render(<Podlite>{pod}</Podlite>);
176
+ expect(renderToStaticMarkup(<Podlite>{pod}</Podlite>)).toMatchInlineSnapshot(`
186
177
  <p id="id">
187
178
  asd
188
179
  <del>
@@ -191,10 +182,10 @@ asd ~~asdsd~~
191
182
  </p>
192
183
  <p>
193
184
  </p>
194
- `);
195
- });
185
+ `)
186
+ })
196
187
 
197
- it("=Markdown: table render", () => {
188
+ it('=Markdown: table render', () => {
198
189
  const pod = `
199
190
  =begin Markdown
200
191
  | Syntax | Description |
@@ -202,10 +193,11 @@ it("=Markdown: table render", () => {
202
193
  | Header | Title |
203
194
  | Paragraph | Text |
204
195
  =end Markdown
205
- `;
196
+ `
206
197
 
207
- render(<Podlite>{pod}</Podlite>);
208
- expect(root.innerHTML).toMatchInlineSnapshot(`
198
+ // render(<Podlite>{pod}</Podlite>);
199
+ // console.log(root.innerHTML);
200
+ expect(renderToStaticMarkup(<Podlite>{pod}</Podlite>)).toMatchInlineSnapshot(`
209
201
  <table id="id">
210
202
  <caption class="caption">
211
203
  </caption>
@@ -238,5 +230,5 @@ it("=Markdown: table render", () => {
238
230
  </table>
239
231
  <p>
240
232
  </p>
241
- `);
242
- });
233
+ `)
234
+ })
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "esnext"
5
+ }
6
+ }
package/tsconfig.json CHANGED
@@ -6,7 +6,8 @@
6
6
  "rootDir": "./src",
7
7
  "baseUrl": ".",
8
8
  "jsx": "react",
9
- "esModuleInterop": true
9
+ "esModuleInterop": true,
10
+ "module": "commonjs",
10
11
  },
11
12
  "references": [
12
13
  {