@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,33 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './autoformat block elements in list items.md?raw';
|
|
4
|
+
import markdownStringFormatted from './autoformat block elements in list items.result.md?raw';
|
|
5
|
+
var out = output({
|
|
6
|
+
type: 'root',
|
|
7
|
+
children: [
|
|
8
|
+
{
|
|
9
|
+
type: 'ul',
|
|
10
|
+
children: [
|
|
11
|
+
{
|
|
12
|
+
type: 'li',
|
|
13
|
+
children: [
|
|
14
|
+
{
|
|
15
|
+
type: 'lic',
|
|
16
|
+
children: [
|
|
17
|
+
{ type: 'text', text: 'this is a blockquote in a list item' },
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
describe('./autoformat block elements in list items.md', function () {
|
|
27
|
+
it('parses the string in the expected AST', function () {
|
|
28
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
29
|
+
});
|
|
30
|
+
it('stringifies the AST into the expect string', function () {
|
|
31
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownStringFormatted);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './autoformat blockquote.result.md?raw';
|
|
4
|
+
undefined;
|
|
5
|
+
var out = output({
|
|
6
|
+
type: 'root',
|
|
7
|
+
children: [
|
|
8
|
+
{ type: 'blockquote', children: [{ type: 'text', text: 'Hello, World!' }] },
|
|
9
|
+
]
|
|
10
|
+
});
|
|
11
|
+
describe('./autoformat blockquote.result.md', function () {
|
|
12
|
+
it('parses the string in the expected AST', function () {
|
|
13
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
14
|
+
});
|
|
15
|
+
it('stringifies the AST into the expect string', function () {
|
|
16
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './autoformat blockquote.md?raw';
|
|
4
|
+
import markdownStringFormatted from './autoformat blockquote.result.md?raw';
|
|
5
|
+
var out = output({
|
|
6
|
+
type: 'root',
|
|
7
|
+
children: [
|
|
8
|
+
{ type: 'blockquote', children: [{ type: 'text', text: 'Hello, World!' }] },
|
|
9
|
+
]
|
|
10
|
+
});
|
|
11
|
+
describe('./autoformat blockquote.md', function () {
|
|
12
|
+
it('parses the string in the expected AST', function () {
|
|
13
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
14
|
+
});
|
|
15
|
+
it('stringifies the AST into the expect string', function () {
|
|
16
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownStringFormatted);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './autoformat list item.md?raw';
|
|
4
|
+
import markdownStringFormatted from './autoformat list item.result.md?raw';
|
|
5
|
+
var out = output({
|
|
6
|
+
type: 'root',
|
|
7
|
+
children: [
|
|
8
|
+
{
|
|
9
|
+
type: 'ul',
|
|
10
|
+
children: [
|
|
11
|
+
{
|
|
12
|
+
type: 'li',
|
|
13
|
+
children: [
|
|
14
|
+
{
|
|
15
|
+
type: 'lic',
|
|
16
|
+
children: [{ type: 'text', text: 'this is a list item' }]
|
|
17
|
+
},
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
describe('./autoformat list item.md', function () {
|
|
25
|
+
it('parses the string in the expected AST', function () {
|
|
26
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
27
|
+
});
|
|
28
|
+
it('stringifies the AST into the expect string', function () {
|
|
29
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownStringFormatted);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -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 './autoformat mdx with nested null children.md?raw';
|
|
4
|
+
import markdownStringFormatted from './autoformat mdx with nested null children.result.md?raw';
|
|
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('./autoformat 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(markdownStringFormatted);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './autoformat syntax changes.md?raw';
|
|
4
|
+
import markdownStringFormatted from './autoformat syntax changes.result.md?raw';
|
|
5
|
+
var out = output({
|
|
6
|
+
type: 'root',
|
|
7
|
+
children: [
|
|
8
|
+
{
|
|
9
|
+
type: 'ul',
|
|
10
|
+
children: [
|
|
11
|
+
{
|
|
12
|
+
type: 'li',
|
|
13
|
+
children: [
|
|
14
|
+
{ type: 'lic', children: [{ type: 'text', text: 'Red' }] },
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: 'li',
|
|
19
|
+
children: [
|
|
20
|
+
{ type: 'lic', children: [{ type: 'text', text: 'Green' }] },
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'li',
|
|
25
|
+
children: [
|
|
26
|
+
{ type: 'lic', children: [{ type: 'text', text: 'Blue' }] },
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'ul',
|
|
33
|
+
children: [
|
|
34
|
+
{
|
|
35
|
+
type: 'li',
|
|
36
|
+
children: [
|
|
37
|
+
{ type: 'lic', children: [{ type: 'text', text: 'Red' }] },
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: 'li',
|
|
42
|
+
children: [
|
|
43
|
+
{ type: 'lic', children: [{ type: 'text', text: 'Green' }] },
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'li',
|
|
48
|
+
children: [
|
|
49
|
+
{ type: 'lic', children: [{ type: 'text', text: 'Blue' }] },
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'p',
|
|
56
|
+
children: [{ type: 'text', text: 'single asterisks', italic: true }]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: 'p',
|
|
60
|
+
children: [{ type: 'text', text: 'single underscores', italic: true }]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: 'p',
|
|
64
|
+
children: [{ type: 'text', text: 'double asterisks', bold: true }]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: 'p',
|
|
68
|
+
children: [{ type: 'text', text: 'double underscores', bold: true }]
|
|
69
|
+
},
|
|
70
|
+
{ type: 'hr', children: [{ type: 'text', text: '' }] },
|
|
71
|
+
{ type: 'hr', children: [{ type: 'text', text: '' }] },
|
|
72
|
+
{ type: 'hr', children: [{ type: 'text', text: '' }] },
|
|
73
|
+
{ type: 'hr', children: [{ type: 'text', text: '' }] },
|
|
74
|
+
{ type: 'h1', children: [{ type: 'text', text: 'Headers' }] },
|
|
75
|
+
{ type: 'h1', children: [{ type: 'text', text: 'Header 1' }] },
|
|
76
|
+
{ type: 'h2', children: [{ type: 'text', text: 'Header 2' }] },
|
|
77
|
+
{
|
|
78
|
+
type: 'h1',
|
|
79
|
+
children: [{ type: 'text', text: 'Indentation is ignored' }]
|
|
80
|
+
},
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
describe('./autoformat syntax changes.md', function () {
|
|
84
|
+
it('parses the string in the expected AST', function () {
|
|
85
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
86
|
+
});
|
|
87
|
+
it('stringifies the AST into the expect string', function () {
|
|
88
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownStringFormatted);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './blockquote.md?raw';
|
|
4
|
+
var out = output({
|
|
5
|
+
type: 'root',
|
|
6
|
+
children: [
|
|
7
|
+
{ type: 'blockquote', children: [{ type: 'text', text: 'Hello, World!' }] },
|
|
8
|
+
]
|
|
9
|
+
});
|
|
10
|
+
describe('./blockquote.md', function () {
|
|
11
|
+
it('parses the string in the expected AST', function () {
|
|
12
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
13
|
+
});
|
|
14
|
+
it('stringifies the AST into the expect string', function () {
|
|
15
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -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 './break.md?raw';
|
|
4
|
+
var out = output({
|
|
5
|
+
type: 'root',
|
|
6
|
+
children: [
|
|
7
|
+
{
|
|
8
|
+
type: 'p',
|
|
9
|
+
children: [
|
|
10
|
+
{ type: 'text', text: '123 Abc Street' },
|
|
11
|
+
{ type: 'break', children: [{ type: 'text', text: '' }] },
|
|
12
|
+
{ type: 'text', text: 'Town Central, CA' },
|
|
13
|
+
{ type: 'break', children: [{ type: 'text', text: '' }] },
|
|
14
|
+
{ type: 'text', text: '90210' },
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
]
|
|
18
|
+
});
|
|
19
|
+
describe('./break.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,27 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './code block.md?raw';
|
|
4
|
+
var out = output({
|
|
5
|
+
type: 'root',
|
|
6
|
+
children: [
|
|
7
|
+
{
|
|
8
|
+
type: 'code_block',
|
|
9
|
+
lang: 'javascript',
|
|
10
|
+
value: 'const test = 123',
|
|
11
|
+
children: [{ type: 'text', text: '' }]
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
type: 'code_block',
|
|
15
|
+
value: 'some random code',
|
|
16
|
+
children: [{ type: 'text', text: '' }]
|
|
17
|
+
},
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
describe('./code block.md', function () {
|
|
21
|
+
it('parses the string in the expected AST', function () {
|
|
22
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
23
|
+
});
|
|
24
|
+
it('stringifies the AST into the expect string', function () {
|
|
25
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './image.md?raw';
|
|
4
|
+
var out = output({
|
|
5
|
+
type: 'root',
|
|
6
|
+
children: [
|
|
7
|
+
{
|
|
8
|
+
type: 'p',
|
|
9
|
+
children: [
|
|
10
|
+
{
|
|
11
|
+
type: 'img',
|
|
12
|
+
url: 'https://some-image.jpg',
|
|
13
|
+
alt: 'alt description',
|
|
14
|
+
caption: 'Some Title',
|
|
15
|
+
children: [{ type: 'text', text: '' }]
|
|
16
|
+
},
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: 'p',
|
|
21
|
+
children: [
|
|
22
|
+
{
|
|
23
|
+
type: 'img',
|
|
24
|
+
url: 'https://some-image.jpg',
|
|
25
|
+
alt: '',
|
|
26
|
+
caption: 'Some title',
|
|
27
|
+
children: [{ type: 'text', text: '' }]
|
|
28
|
+
},
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'p',
|
|
33
|
+
children: [
|
|
34
|
+
{
|
|
35
|
+
type: 'img',
|
|
36
|
+
url: 'https://some-image.jpg',
|
|
37
|
+
alt: '',
|
|
38
|
+
caption: null,
|
|
39
|
+
children: [{ type: 'text', text: '' }]
|
|
40
|
+
},
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
]
|
|
44
|
+
});
|
|
45
|
+
describe('./image.md', function () {
|
|
46
|
+
it('parses the string in the expected AST', function () {
|
|
47
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
48
|
+
});
|
|
49
|
+
it('stringifies the AST into the expect string', function () {
|
|
50
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './invalid mdx with a closing tag.md?raw';
|
|
4
|
+
undefined;
|
|
5
|
+
var out = output({
|
|
6
|
+
type: 'root',
|
|
7
|
+
children: [
|
|
8
|
+
{
|
|
9
|
+
type: 'invalid_markdown',
|
|
10
|
+
value: 'This is a </a> broken html tag\n',
|
|
11
|
+
message: '1:12-1:13: Unexpected closing slash `/` in tag, expected an open tag first',
|
|
12
|
+
children: [{ type: 'text', text: '' }],
|
|
13
|
+
position: {
|
|
14
|
+
start: { line: 1, column: 12, offset: 11, _index: 0, _bufferIndex: 11 },
|
|
15
|
+
end: { line: 1, column: 13, offset: 12, _index: 0, _bufferIndex: 12 }
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
describe('./invalid mdx with a closing tag.md', function () {
|
|
21
|
+
it('parses the string in the expected AST', function () {
|
|
22
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
23
|
+
});
|
|
24
|
+
it('stringifies the AST into the expect string', function () {
|
|
25
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './invalid mdx with a const expression.md?raw';
|
|
4
|
+
undefined;
|
|
5
|
+
var out = output({
|
|
6
|
+
type: 'root',
|
|
7
|
+
children: [
|
|
8
|
+
{
|
|
9
|
+
type: 'invalid_markdown',
|
|
10
|
+
value: 'export const a = "b"\n',
|
|
11
|
+
message: 'Unexpected expression export const a = "b".',
|
|
12
|
+
children: [{ type: 'text', text: '' }],
|
|
13
|
+
position: {
|
|
14
|
+
start: { line: 1, column: 1, offset: 0 },
|
|
15
|
+
end: { line: 1, column: 21, offset: 20 }
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
describe('./invalid mdx with a const expression.md', function () {
|
|
21
|
+
it('parses the string in the expected AST', function () {
|
|
22
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
23
|
+
});
|
|
24
|
+
it('stringifies the AST into the expect string', function () {
|
|
25
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './invalid mdx with an expression {{}}.md?raw';
|
|
4
|
+
undefined;
|
|
5
|
+
var out = output({
|
|
6
|
+
type: 'root',
|
|
7
|
+
children: [
|
|
8
|
+
{
|
|
9
|
+
type: 'invalid_markdown',
|
|
10
|
+
value: 'Hello {{ world! }}\n',
|
|
11
|
+
message: '1:15: Could not parse expression with acorn: Unexpected token',
|
|
12
|
+
children: [{ type: 'text', text: '' }],
|
|
13
|
+
position: {
|
|
14
|
+
start: { line: 1, column: 15, offset: 14 },
|
|
15
|
+
end: { line: null, column: null }
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
describe('./invalid mdx with an expression {{}}.md', function () {
|
|
21
|
+
it('parses the string in the expected AST', function () {
|
|
22
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
23
|
+
});
|
|
24
|
+
it('stringifies the AST into the expect string', function () {
|
|
25
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './invalid mdx with an expression.md?raw';
|
|
4
|
+
undefined;
|
|
5
|
+
var out = output({
|
|
6
|
+
type: 'root',
|
|
7
|
+
children: [
|
|
8
|
+
{
|
|
9
|
+
type: 'invalid_markdown',
|
|
10
|
+
value: '<Greeting message={() => "hello"} />\n',
|
|
11
|
+
message: 'Unable to parse field value for field "message" (type: string). Expected type to be Literal but received ArrowFunctionExpression. TinaCMS supports a stricter version of markdown and a subset of MDX. https://tina.io/docs/editing/mdx/#differences-from-other-mdx-implementations',
|
|
12
|
+
children: [{ type: 'text', text: '' }],
|
|
13
|
+
position: {
|
|
14
|
+
start: { line: 1, column: 1, offset: 0 },
|
|
15
|
+
end: { line: 1, column: 37, offset: 36 }
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
describe('./invalid mdx with an expression.md', function () {
|
|
21
|
+
it('parses the string in the expected AST', function () {
|
|
22
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
23
|
+
});
|
|
24
|
+
it('stringifies the AST into the expect string', function () {
|
|
25
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { field, output, parseMDX, stringifyMDX } from './_config';
|
|
3
|
+
import markdownString from './invalid mdx with an import statment.md?raw';
|
|
4
|
+
undefined;
|
|
5
|
+
var out = output({
|
|
6
|
+
type: 'root',
|
|
7
|
+
children: [
|
|
8
|
+
{
|
|
9
|
+
type: 'invalid_markdown',
|
|
10
|
+
value: 'import { a } from "./b"\n',
|
|
11
|
+
message: 'Unexpected expression import { a } from "./b".',
|
|
12
|
+
children: [{ type: 'text', text: '' }],
|
|
13
|
+
position: {
|
|
14
|
+
start: { line: 1, column: 1, offset: 0 },
|
|
15
|
+
end: { line: 1, column: 24, offset: 23 }
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
describe('./invalid mdx with an import statment.md', function () {
|
|
21
|
+
it('parses the string in the expected AST', function () {
|
|
22
|
+
expect(parseMDX(markdownString, field, function (v) { return v; })).toMatchObject(out);
|
|
23
|
+
});
|
|
24
|
+
it('stringifies the AST into the expect string', function () {
|
|
25
|
+
expect(stringifyMDX(out, field, function (v) { return v; })).toEqual(markdownString);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|