@tinacms/mdx 0.0.0-20220718181631 → 0.60.3
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/dist/index.cjs +887 -738
- package/dist/index.d.ts +21 -1
- package/dist/index.es.js +546 -406
- package/dist/{parse/plate-spec.d.ts → index.js} +4 -2
- package/dist/mdx.es.js +1092 -0
- package/dist/mdx.umd.js +1097 -0
- package/dist/parse/acorn.d.ts +2 -3
- package/dist/parse/acorn.js +201 -0
- package/dist/parse/index.d.ts +8 -2
- package/dist/parse/index.js +144 -0
- package/dist/parse/mdx.js +75 -0
- package/dist/parse/plate.d.ts +15 -2
- package/dist/parse/plate.js +1 -0
- package/dist/parse/remarkToPlate.d.ts +16 -1
- package/dist/parse/remarkToPlate.js +380 -0
- package/dist/stringify/acorn.d.ts +7 -2
- package/dist/stringify/acorn.js +241 -0
- package/dist/stringify/index.d.ts +15 -0
- package/dist/stringify/index.js +195 -0
- package/dist/stringify/marks.js +250 -0
- package/dist/tests/autotest/_config.d.ts +4 -0
- package/dist/tests/autotest/_config.js +159 -0
- package/dist/tests/autotest/_runner.test.d.ts +1 -0
- package/dist/tests/autotest/_runner.test.js +77 -0
- package/dist/tests/autotest/autoformat block elements in list items.test.d.ts +1 -0
- package/dist/tests/autotest/autoformat block elements in list items.test.js +33 -0
- package/dist/tests/autotest/autoformat blockquote.result.test.d.ts +1 -0
- package/dist/tests/autotest/autoformat blockquote.result.test.js +18 -0
- package/dist/tests/autotest/autoformat blockquote.test.d.ts +1 -0
- package/dist/tests/autotest/autoformat blockquote.test.js +18 -0
- package/dist/tests/autotest/autoformat list item.test.d.ts +1 -0
- package/dist/tests/autotest/autoformat list item.test.js +31 -0
- package/dist/tests/autotest/autoformat mdx with nested null children.test.d.ts +1 -0
- package/dist/tests/autotest/autoformat mdx with nested null children.test.js +23 -0
- package/dist/tests/autotest/autoformat syntax changes.test.d.ts +1 -0
- package/dist/tests/autotest/autoformat syntax changes.test.js +90 -0
- package/dist/tests/autotest/blockquote.test.d.ts +1 -0
- package/dist/tests/autotest/blockquote.test.js +17 -0
- package/dist/tests/autotest/break.test.d.ts +1 -0
- package/dist/tests/autotest/break.test.js +26 -0
- package/dist/tests/autotest/code block.test.d.ts +1 -0
- package/dist/tests/autotest/code block.test.js +27 -0
- package/dist/tests/autotest/image.test.d.ts +1 -0
- package/dist/tests/autotest/image.test.js +52 -0
- package/dist/tests/autotest/invalid mdx with a closing tag.test.d.ts +1 -0
- package/dist/tests/autotest/invalid mdx with a closing tag.test.js +27 -0
- package/dist/tests/autotest/invalid mdx with a const expression.test.d.ts +1 -0
- package/dist/tests/autotest/invalid mdx with a const expression.test.js +27 -0
- package/dist/tests/autotest/invalid mdx with an expression {{}}.test.d.ts +1 -0
- package/dist/tests/autotest/invalid mdx with an expression {{}}.test.js +27 -0
- package/dist/tests/autotest/invalid mdx with an expression.test.d.ts +1 -0
- package/dist/tests/autotest/invalid mdx with an expression.test.js +27 -0
- package/dist/tests/autotest/invalid mdx with an import statment.test.d.ts +1 -0
- package/dist/tests/autotest/invalid mdx with an import statment.test.js +27 -0
- package/dist/tests/autotest/kitchen sink.test.d.ts +1 -0
- package/dist/tests/autotest/kitchen sink.test.js +144 -0
- package/dist/tests/autotest/links.test.d.ts +1 -0
- package/dist/tests/autotest/links.test.js +29 -0
- package/dist/tests/autotest/lists.test.d.ts +1 -0
- package/dist/tests/autotest/lists.test.js +110 -0
- package/dist/tests/autotest/marks.test.d.ts +1 -0
- package/dist/tests/autotest/marks.test.js +102 -0
- package/dist/tests/autotest/mdx field with a scalar field as a list.test.d.ts +1 -0
- package/dist/tests/autotest/mdx field with a scalar field as a list.test.js +22 -0
- package/dist/tests/autotest/mdx which hasnt been registered returns html.test.d.ts +1 -0
- package/dist/tests/autotest/mdx which hasnt been registered returns html.test.js +26 -0
- package/dist/tests/autotest/mdx with a boolean field.test.d.ts +1 -0
- package/dist/tests/autotest/mdx with a boolean field.test.js +22 -0
- package/dist/tests/autotest/mdx with a number field.test.d.ts +1 -0
- package/dist/tests/autotest/mdx with a number field.test.js +22 -0
- package/dist/tests/autotest/mdx with a srtring field.test.d.ts +1 -0
- package/dist/tests/autotest/mdx with a srtring field.test.js +28 -0
- package/dist/tests/autotest/mdx with multiple rich-text fields.test.d.ts +1 -0
- package/dist/tests/autotest/mdx with multiple rich-text fields.test.js +53 -0
- package/dist/tests/autotest/mdx with nested children.test.d.ts +1 -0
- package/dist/tests/autotest/mdx with nested children.test.js +35 -0
- package/dist/tests/autotest/mdx with nested null children.test.d.ts +1 -0
- package/dist/tests/autotest/mdx with nested null children.test.js +23 -0
- package/dist/tests/autotest/mdx with number list field.test.d.ts +1 -0
- package/dist/tests/autotest/mdx with number list field.test.js +22 -0
- package/dist/tests/autotest/mdx with object list field.test.d.ts +1 -0
- package/dist/tests/autotest/mdx with object list field.test.js +25 -0
- package/dist/tests/autotest/mdx with object with templates.test.d.ts +1 -0
- package/dist/tests/autotest/mdx with object with templates.test.js +41 -0
- package/dist/tests/autotest/shortcodes.test.d.ts +1 -0
- package/dist/tests/autotest/shortcodes.test.js +51 -0
- package/dist/tests/setup.d.ts +14 -0
- package/dist/tests/setup.js +70 -0
- package/package.json +13 -14
- package/dist/stringify/mdx.d.ts +0 -38
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './kitchen sink.md?raw';
|
|
4
|
+
var out = output({
|
|
5
|
+
type: 'root',
|
|
6
|
+
children: [
|
|
7
|
+
{ type: 'p', children: [{ type: 'text', text: 'This is a paragraph.' }] },
|
|
8
|
+
{ type: 'h1', children: [{ type: 'text', text: 'Header 1' }] },
|
|
9
|
+
{ type: 'h2', children: [{ type: 'text', text: 'Header 2' }] },
|
|
10
|
+
{ type: 'h3', children: [{ type: 'text', text: 'Header 3' }] },
|
|
11
|
+
{ type: 'h4', children: [{ type: 'text', text: 'Header 4' }] },
|
|
12
|
+
{ type: 'h5', children: [{ type: 'text', text: 'Header 5' }] },
|
|
13
|
+
{ type: 'h6', children: [{ type: 'text', text: 'Header 6' }] },
|
|
14
|
+
{
|
|
15
|
+
type: 'blockquote',
|
|
16
|
+
children: [
|
|
17
|
+
{
|
|
18
|
+
type: 'text',
|
|
19
|
+
text: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.'
|
|
20
|
+
},
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'ul',
|
|
25
|
+
children: [
|
|
26
|
+
{
|
|
27
|
+
type: 'li',
|
|
28
|
+
children: [
|
|
29
|
+
{ type: 'lic', children: [{ type: 'text', text: 'Red' }] },
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: 'li',
|
|
34
|
+
children: [
|
|
35
|
+
{ type: 'lic', children: [{ type: 'text', text: 'Green' }] },
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: 'li',
|
|
40
|
+
children: [
|
|
41
|
+
{ type: 'lic', children: [{ type: 'text', text: 'Blue' }] },
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'code_block',
|
|
48
|
+
lang: 'markdown',
|
|
49
|
+
value: '- Red\n- Green\n- Blue',
|
|
50
|
+
children: [{ type: 'text', text: '' }]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: 'ol',
|
|
54
|
+
children: [
|
|
55
|
+
{
|
|
56
|
+
type: 'li',
|
|
57
|
+
children: [
|
|
58
|
+
{
|
|
59
|
+
type: 'lic',
|
|
60
|
+
children: [{ type: 'text', text: 'Buy flour and salt' }]
|
|
61
|
+
},
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: 'li',
|
|
66
|
+
children: [
|
|
67
|
+
{
|
|
68
|
+
type: 'lic',
|
|
69
|
+
children: [{ type: 'text', text: 'Mix together with water' }]
|
|
70
|
+
},
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: 'li',
|
|
75
|
+
children: [
|
|
76
|
+
{ type: 'lic', children: [{ type: 'text', text: 'Bake' }] },
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
{ type: 'hr', children: [{ type: 'text', text: '' }] },
|
|
82
|
+
{
|
|
83
|
+
type: 'p',
|
|
84
|
+
children: [
|
|
85
|
+
{ type: 'text', text: 'This is ' },
|
|
86
|
+
{
|
|
87
|
+
type: 'a',
|
|
88
|
+
url: 'http://example.com',
|
|
89
|
+
title: 'Example',
|
|
90
|
+
children: [{ type: 'text', text: 'an example' }]
|
|
91
|
+
},
|
|
92
|
+
{ type: 'text', text: ' link.' },
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: 'p',
|
|
97
|
+
children: [
|
|
98
|
+
{
|
|
99
|
+
type: 'a',
|
|
100
|
+
url: 'http://example.com',
|
|
101
|
+
title: null,
|
|
102
|
+
children: [{ type: 'text', text: 'This link' }]
|
|
103
|
+
},
|
|
104
|
+
{ type: 'text', text: ' has no title attr.' },
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: 'p',
|
|
109
|
+
children: [{ type: 'text', text: 'single asterisks', italic: true }]
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
type: 'p',
|
|
113
|
+
children: [{ type: 'text', text: 'double asterisks', bold: true }]
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
type: 'p',
|
|
117
|
+
children: [
|
|
118
|
+
{ type: 'text', text: 'This paragraph has some ' },
|
|
119
|
+
{ type: 'text', text: 'code', code: true },
|
|
120
|
+
{ type: 'text', text: ' in it.' },
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
type: 'p',
|
|
125
|
+
children: [
|
|
126
|
+
{
|
|
127
|
+
type: 'img',
|
|
128
|
+
url: 'https://get.svg.workers.dev',
|
|
129
|
+
alt: 'Alt Text',
|
|
130
|
+
caption: 'Image Title',
|
|
131
|
+
children: [{ type: 'text', text: '' }]
|
|
132
|
+
},
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
]
|
|
136
|
+
});
|
|
137
|
+
describe('./kitchen sink.md', function () {
|
|
138
|
+
it('parses the string in the expected AST', function () {
|
|
139
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
140
|
+
});
|
|
141
|
+
it('stringifies the AST into the expect string', function () {
|
|
142
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './links.md?raw';
|
|
4
|
+
var out = output({
|
|
5
|
+
type: 'root',
|
|
6
|
+
children: [
|
|
7
|
+
{
|
|
8
|
+
type: 'p',
|
|
9
|
+
children: [
|
|
10
|
+
{ type: 'text', text: 'Click ' },
|
|
11
|
+
{
|
|
12
|
+
type: 'a',
|
|
13
|
+
url: 'https://example.com',
|
|
14
|
+
title: 'Tester',
|
|
15
|
+
children: [{ type: 'text', text: 'here' }]
|
|
16
|
+
},
|
|
17
|
+
{ type: 'text', text: ' to join now' },
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
describe('./links.md', function () {
|
|
23
|
+
it('parses the string in the expected AST', function () {
|
|
24
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
25
|
+
});
|
|
26
|
+
it('stringifies the AST into the expect string', function () {
|
|
27
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './lists.md?raw';
|
|
4
|
+
var out = output({
|
|
5
|
+
type: 'root',
|
|
6
|
+
children: [
|
|
7
|
+
{
|
|
8
|
+
type: 'ul',
|
|
9
|
+
children: [
|
|
10
|
+
{
|
|
11
|
+
type: 'li',
|
|
12
|
+
children: [
|
|
13
|
+
{
|
|
14
|
+
type: 'lic',
|
|
15
|
+
children: [{ type: 'text', text: 'This is an item' }]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: 'ul',
|
|
19
|
+
children: [
|
|
20
|
+
{
|
|
21
|
+
type: 'li',
|
|
22
|
+
children: [
|
|
23
|
+
{
|
|
24
|
+
type: 'lic',
|
|
25
|
+
children: [{ type: 'text', text: 'this is a sub-item' }]
|
|
26
|
+
},
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: 'li',
|
|
35
|
+
children: [
|
|
36
|
+
{
|
|
37
|
+
type: 'lic',
|
|
38
|
+
children: [{ type: 'text', text: 'this is another item' }]
|
|
39
|
+
},
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{ type: 'hr', children: [{ type: 'text', text: '' }] },
|
|
45
|
+
{
|
|
46
|
+
type: 'ul',
|
|
47
|
+
children: [
|
|
48
|
+
{
|
|
49
|
+
type: 'li',
|
|
50
|
+
children: [
|
|
51
|
+
{
|
|
52
|
+
type: 'lic',
|
|
53
|
+
children: [
|
|
54
|
+
{ type: 'text', text: 'this is an ' },
|
|
55
|
+
{ type: 'text', text: 'item', bold: true },
|
|
56
|
+
{ type: 'text', text: ' and a ' },
|
|
57
|
+
{
|
|
58
|
+
type: 'a',
|
|
59
|
+
url: 'http://example.com',
|
|
60
|
+
title: null,
|
|
61
|
+
children: [{ type: 'text', text: 'link' }]
|
|
62
|
+
},
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
{ type: 'hr', children: [{ type: 'text', text: '' }] },
|
|
70
|
+
{
|
|
71
|
+
type: 'ul',
|
|
72
|
+
children: [
|
|
73
|
+
{
|
|
74
|
+
type: 'li',
|
|
75
|
+
children: [
|
|
76
|
+
{ type: 'lic', children: [{ type: 'text', text: 'list item 1' }] },
|
|
77
|
+
{
|
|
78
|
+
type: 'ol',
|
|
79
|
+
children: [
|
|
80
|
+
{
|
|
81
|
+
type: 'li',
|
|
82
|
+
children: [
|
|
83
|
+
{
|
|
84
|
+
type: 'lic',
|
|
85
|
+
children: [{ type: 'text', text: 'sub list item 1A' }]
|
|
86
|
+
},
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
type: 'li',
|
|
95
|
+
children: [
|
|
96
|
+
{ type: 'lic', children: [{ type: 'text', text: 'list item 2' }] },
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
]
|
|
102
|
+
});
|
|
103
|
+
describe('./lists.md', function () {
|
|
104
|
+
it('parses the string in the expected AST', function () {
|
|
105
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
106
|
+
});
|
|
107
|
+
it('stringifies the AST into the expect string', function () {
|
|
108
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './marks.md?raw';
|
|
4
|
+
var out = output({
|
|
5
|
+
type: 'root',
|
|
6
|
+
children: [
|
|
7
|
+
{
|
|
8
|
+
type: 'p',
|
|
9
|
+
children: [
|
|
10
|
+
{ type: 'text', text: 'Some ' },
|
|
11
|
+
{ type: 'text', text: 'bold', bold: true },
|
|
12
|
+
{ type: 'text', text: ' text' },
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
type: 'p',
|
|
17
|
+
children: [
|
|
18
|
+
{ type: 'text', text: 'Some ' },
|
|
19
|
+
{ type: 'text', text: 'bold and emphasized', italic: true, bold: true },
|
|
20
|
+
{ type: 'text', text: ' text' },
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'p',
|
|
25
|
+
children: [
|
|
26
|
+
{ type: 'text', text: 'Marks with ' },
|
|
27
|
+
{ type: 'text', text: 'emphasized text nesting ', italic: true },
|
|
28
|
+
{ type: 'text', text: 'bold', italic: true, bold: true },
|
|
29
|
+
{ type: 'text', text: ' text', italic: true },
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: 'p',
|
|
34
|
+
children: [
|
|
35
|
+
{ type: 'text', text: 'Hello ', bold: true },
|
|
36
|
+
{ type: 'text', text: 'world', bold: true, italic: true },
|
|
37
|
+
{ type: 'text', text: ', again', bold: true },
|
|
38
|
+
{ type: 'text', text: ' ' },
|
|
39
|
+
{ type: 'text', text: 'here', italic: true },
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: 'p',
|
|
44
|
+
children: [
|
|
45
|
+
{ type: 'text', text: 'Some ' },
|
|
46
|
+
{ type: 'text', text: 'inline code', code: true },
|
|
47
|
+
{ type: 'text', text: ' examples' },
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'p',
|
|
52
|
+
children: [
|
|
53
|
+
{ type: 'text', text: 'Hello ', italic: true },
|
|
54
|
+
{ type: 'text', text: 'some code', code: true, italic: true },
|
|
55
|
+
{ type: 'text', text: ', again', italic: true },
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: 'p',
|
|
60
|
+
children: [
|
|
61
|
+
{ type: 'text', text: 'Hello ', bold: true },
|
|
62
|
+
{
|
|
63
|
+
type: 'a',
|
|
64
|
+
url: 'https://example.com',
|
|
65
|
+
title: 'Example Site',
|
|
66
|
+
children: [{ type: 'text', text: 'world', bold: true }]
|
|
67
|
+
},
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: 'p',
|
|
72
|
+
children: [
|
|
73
|
+
{ type: 'text', text: 'Hello ', italic: true, bold: true },
|
|
74
|
+
{
|
|
75
|
+
type: 'a',
|
|
76
|
+
url: 'https://example.com',
|
|
77
|
+
title: 'Example Site',
|
|
78
|
+
children: [{ type: 'text', text: 'world', italic: true, bold: true }]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: 'text',
|
|
82
|
+
text: ' And some other text, which has a ',
|
|
83
|
+
italic: true
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
type: 'a',
|
|
87
|
+
url: 'https://something.com',
|
|
88
|
+
title: null,
|
|
89
|
+
children: [{ type: 'text', text: 'link to something', italic: true }]
|
|
90
|
+
},
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
describe('./marks.md', function () {
|
|
96
|
+
it('parses the string in the expected AST', function () {
|
|
97
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
98
|
+
});
|
|
99
|
+
it('stringifies the AST into the expect string', function () {
|
|
100
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './mdx field with a scalar field as a list.md?raw';
|
|
4
|
+
var out = output({
|
|
5
|
+
type: 'root',
|
|
6
|
+
children: [
|
|
7
|
+
{
|
|
8
|
+
type: 'mdxJsxFlowElement',
|
|
9
|
+
name: 'Ratings',
|
|
10
|
+
children: [{ type: 'text', text: '' }],
|
|
11
|
+
props: { value: [1, 2, 3] }
|
|
12
|
+
},
|
|
13
|
+
]
|
|
14
|
+
});
|
|
15
|
+
describe('./mdx field with a scalar field as a list.md', function () {
|
|
16
|
+
it('parses the string in the expected AST', function () {
|
|
17
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
18
|
+
});
|
|
19
|
+
it('stringifies the AST into the expect string', function () {
|
|
20
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './mdx which hasnt been registered returns html.md?raw';
|
|
4
|
+
var out = output({
|
|
5
|
+
type: 'root',
|
|
6
|
+
children: [
|
|
7
|
+
{
|
|
8
|
+
type: 'html',
|
|
9
|
+
value: '<SomeUnregisteredComponen hello="world" />',
|
|
10
|
+
children: [{ type: 'text', text: '' }]
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
type: 'html',
|
|
14
|
+
value: '<SomeUnregisteredComponen>\n # Some markdown in the child\n</SomeUnregisteredComponen>',
|
|
15
|
+
children: [{ type: 'text', text: '' }]
|
|
16
|
+
},
|
|
17
|
+
]
|
|
18
|
+
});
|
|
19
|
+
describe('./mdx which hasnt been registered returns html.md', function () {
|
|
20
|
+
it('parses the string in the expected AST', function () {
|
|
21
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
22
|
+
});
|
|
23
|
+
it('stringifies the AST into the expect string', function () {
|
|
24
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './mdx with a boolean field.md?raw';
|
|
4
|
+
var out = output({
|
|
5
|
+
type: 'root',
|
|
6
|
+
children: [
|
|
7
|
+
{
|
|
8
|
+
type: 'mdxJsxFlowElement',
|
|
9
|
+
name: 'MaybeShow',
|
|
10
|
+
children: [{ type: 'text', text: '' }],
|
|
11
|
+
props: { toggle: true }
|
|
12
|
+
},
|
|
13
|
+
]
|
|
14
|
+
});
|
|
15
|
+
describe('./mdx with a boolean field.md', function () {
|
|
16
|
+
it('parses the string in the expected AST', function () {
|
|
17
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
18
|
+
});
|
|
19
|
+
it('stringifies the AST into the expect string', function () {
|
|
20
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './mdx with a number field.md?raw';
|
|
4
|
+
var out = output({
|
|
5
|
+
type: 'root',
|
|
6
|
+
children: [
|
|
7
|
+
{
|
|
8
|
+
type: 'mdxJsxFlowElement',
|
|
9
|
+
name: 'Count',
|
|
10
|
+
children: [{ type: 'text', text: '' }],
|
|
11
|
+
props: { number: 1 }
|
|
12
|
+
},
|
|
13
|
+
]
|
|
14
|
+
});
|
|
15
|
+
describe('./mdx with a number field.md', function () {
|
|
16
|
+
it('parses the string in the expected AST', function () {
|
|
17
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
18
|
+
});
|
|
19
|
+
it('stringifies the AST into the expect string', function () {
|
|
20
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './mdx with a srtring field.md?raw';
|
|
4
|
+
var out = output({
|
|
5
|
+
type: 'root',
|
|
6
|
+
children: [
|
|
7
|
+
{
|
|
8
|
+
type: 'p',
|
|
9
|
+
children: [
|
|
10
|
+
{
|
|
11
|
+
type: 'mdxJsxTextElement',
|
|
12
|
+
name: 'Greeting',
|
|
13
|
+
children: [{ type: 'text', text: '' }],
|
|
14
|
+
props: { message: 'Hello' }
|
|
15
|
+
},
|
|
16
|
+
{ type: 'text', text: ' world!' },
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
]
|
|
20
|
+
});
|
|
21
|
+
describe('./mdx with a srtring field.md', function () {
|
|
22
|
+
it('parses the string in the expected AST', function () {
|
|
23
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
24
|
+
});
|
|
25
|
+
it('stringifies the AST into the expect string', function () {
|
|
26
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './mdx with multiple rich-text fields.md?raw';
|
|
4
|
+
var out = output({
|
|
5
|
+
type: 'root',
|
|
6
|
+
children: [
|
|
7
|
+
{
|
|
8
|
+
type: 'mdxJsxFlowElement',
|
|
9
|
+
name: 'Cta',
|
|
10
|
+
children: [{ type: 'text', text: '' }],
|
|
11
|
+
props: {
|
|
12
|
+
description: {
|
|
13
|
+
type: 'root',
|
|
14
|
+
children: [
|
|
15
|
+
{
|
|
16
|
+
type: 'p',
|
|
17
|
+
children: [
|
|
18
|
+
{ type: 'text', text: 'Read our privacy policy ' },
|
|
19
|
+
{
|
|
20
|
+
type: 'a',
|
|
21
|
+
url: 'http://example.com',
|
|
22
|
+
title: null,
|
|
23
|
+
children: [{ type: 'text', text: 'here' }]
|
|
24
|
+
},
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
children: {
|
|
30
|
+
type: 'root',
|
|
31
|
+
children: [
|
|
32
|
+
{
|
|
33
|
+
type: 'p',
|
|
34
|
+
children: [
|
|
35
|
+
{ type: 'text', text: 'Click ' },
|
|
36
|
+
{ type: 'text', text: 'here', bold: true },
|
|
37
|
+
{ type: 'text', text: '!' },
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
describe('./mdx with multiple rich-text fields.md', function () {
|
|
47
|
+
it('parses the string in the expected AST', function () {
|
|
48
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
49
|
+
});
|
|
50
|
+
it('stringifies the AST into the expect string', function () {
|
|
51
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './mdx with nested children.md?raw';
|
|
4
|
+
var out = output({
|
|
5
|
+
type: 'root',
|
|
6
|
+
children: [
|
|
7
|
+
{
|
|
8
|
+
type: 'mdxJsxFlowElement',
|
|
9
|
+
name: 'Blockquote',
|
|
10
|
+
children: [{ type: 'text', text: '' }],
|
|
11
|
+
props: {
|
|
12
|
+
author: 'Pedro',
|
|
13
|
+
children: {
|
|
14
|
+
type: 'root',
|
|
15
|
+
children: [
|
|
16
|
+
{
|
|
17
|
+
type: 'h1',
|
|
18
|
+
children: [
|
|
19
|
+
{ type: 'text', text: 'here is some nested rich text' },
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
describe('./mdx with nested children.md', function () {
|
|
29
|
+
it('parses the string in the expected AST', function () {
|
|
30
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
31
|
+
});
|
|
32
|
+
it('stringifies the AST into the expect string', function () {
|
|
33
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './mdx with nested null children.md?raw';
|
|
4
|
+
undefined;
|
|
5
|
+
var out = output({
|
|
6
|
+
type: 'root',
|
|
7
|
+
children: [
|
|
8
|
+
{
|
|
9
|
+
type: 'mdxJsxFlowElement',
|
|
10
|
+
name: 'Blockquote',
|
|
11
|
+
children: [{ type: 'text', text: '' }],
|
|
12
|
+
props: { author: 'Pedro', children: { type: 'root', children: [] } }
|
|
13
|
+
},
|
|
14
|
+
]
|
|
15
|
+
});
|
|
16
|
+
describe('./mdx with nested null children.md', function () {
|
|
17
|
+
it('parses the string in the expected AST', function () {
|
|
18
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
19
|
+
});
|
|
20
|
+
it('stringifies the AST into the expect string', function () {
|
|
21
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|