diff --git a/__tests__/browser/__image_snapshots__/markdown-test-js-visual-regression-tests-rdmd-syntax-renders-callout-tests-without-surprises-1-snap.png b/__tests__/browser/__image_snapshots__/markdown-test-js-visual-regression-tests-rdmd-syntax-renders-callout-tests-without-surprises-1-snap.png
index 9c0f106bb..2b3a70cd9 100644
Binary files a/__tests__/browser/__image_snapshots__/markdown-test-js-visual-regression-tests-rdmd-syntax-renders-callout-tests-without-surprises-1-snap.png and b/__tests__/browser/__image_snapshots__/markdown-test-js-visual-regression-tests-rdmd-syntax-renders-callout-tests-without-surprises-1-snap.png differ
diff --git a/__tests__/browser/__image_snapshots__/markdown-test-js-visual-regression-tests-rdmd-syntax-renders-embeds-without-surprises-1-snap.png b/__tests__/browser/__image_snapshots__/markdown-test-js-visual-regression-tests-rdmd-syntax-renders-embeds-without-surprises-1-snap.png
index 627d1a58e..00f30622e 100644
Binary files a/__tests__/browser/__image_snapshots__/markdown-test-js-visual-regression-tests-rdmd-syntax-renders-embeds-without-surprises-1-snap.png and b/__tests__/browser/__image_snapshots__/markdown-test-js-visual-regression-tests-rdmd-syntax-renders-embeds-without-surprises-1-snap.png differ
diff --git a/__tests__/compilers/compatability.test.ts b/__tests__/compilers/compatability.test.ts
new file mode 100644
index 000000000..33b2d7e8b
--- /dev/null
+++ b/__tests__/compilers/compatability.test.ts
@@ -0,0 +1,49 @@
+import { mdx } from '../../index';
+
+describe('compatability with RDMD', () => {
+ it('compiles variable nodes', () => {
+ const ast = {
+ type: 'readme-variable',
+ text: 'parliament',
+ data: {
+ hName: 'readme-variable',
+ hProperties: {
+ variable: 'parliament',
+ },
+ },
+ };
+
+ expect(mdx(ast).trim()).toBe('
"`); + expect(container.innerHTML).toMatchInlineSnapshot(`"Callout with no title.
"`); cleanup(); }); diff --git a/__tests__/parsers/__snapshots__/callouts.test.js.snap b/__tests__/parsers/__snapshots__/callouts.test.js.snap index a993d76e9..001cd713f 100644 --- a/__tests__/parsers/__snapshots__/callouts.test.js.snap +++ b/__tests__/parsers/__snapshots__/callouts.test.js.snap @@ -21,7 +21,7 @@ exports[`Parse RDMD Callouts > renders an info callout 1`] = ` }, }, "type": "text", - "value": "âšī¸ Info Callout", + "value": "Info Callout", }, ], "position": { @@ -72,6 +72,13 @@ exports[`Parse RDMD Callouts > renders an info callout 1`] = ` "type": "paragraph", }, ], + "data": { + "hName": "Callout", + "hProperties": { + "empty": false, + "icon": "âšī¸", + }, + }, "position": { "end": { "column": 60, @@ -84,7 +91,7 @@ exports[`Parse RDMD Callouts > renders an info callout 1`] = ` "offset": 1, }, }, - "type": "blockquote", + "type": "rdme-callout", }, ], "position": { diff --git a/__tests__/parsers/callouts.test.js b/__tests__/parsers/callouts.test.js index e334106d4..89b833589 100644 --- a/__tests__/parsers/callouts.test.js +++ b/__tests__/parsers/callouts.test.js @@ -1,6 +1,6 @@ import { mdast } from '../../index'; -describe.skip('Parse RDMD Callouts', () => { +describe('Parse RDMD Callouts', () => { it('renders an info callout', () => { const text = ` > âšī¸ Info Callout @@ -10,18 +10,6 @@ describe.skip('Parse RDMD Callouts', () => { expect(mdast(text)).toMatchSnapshot(); }); - it('supports a default theme', () => { - const text = ` -> đĨ Themeless -> -> Lorem ipsum dolor sit amet consectetur adipisicing elit.`; - - const tree = mdast(text); - - expect(tree.children[0].type).toBe('rdme-callout'); - expect(tree.children[0].data.hProperties.theme).toBe('default'); - }); - it('parses a callout with no title', () => { const text = ` > âšī¸ @@ -31,8 +19,8 @@ describe.skip('Parse RDMD Callouts', () => { const tree = mdast(text); expect(tree.children[0].type).toBe('rdme-callout'); - expect(tree.children[0].data.hProperties.theme).toBe('info'); - expect(tree.children[0].data.hProperties.title).toBe(''); + expect(tree.children[0].data.hProperties.icon).toBe('âšī¸'); + expect(tree.children[0].data.hProperties.empty).toBe(true); }); describe('edge cases', () => { @@ -44,8 +32,8 @@ describe.skip('Parse RDMD Callouts', () => { `; const tree = mdast(text); - expect(tree.children[0].data.hProperties.value).toBe('With html!'); - expect(tree.children[0].children[1].children[0].type).toBe('html'); + expect(tree.children[0].children[1].children[0].children[0].value).toBe('With html!'); + expect(tree.children[0].children[1].children[0].type).toBe('mdxJsxTextElement'); }); it('allows trailing spaces after the icon', () => { @@ -56,7 +44,7 @@ describe.skip('Parse RDMD Callouts', () => { const tree = mdast(text); expect(tree.children[0].data.hProperties.icon).toBe('đ'); expect(tree.children[0].children[0].children[0].value).toBe( - 'Compact headings must be followed by two line breaks before the following block.' + 'Compact headings must be followed by two line breaks before the following block.', ); }); }); @@ -83,20 +71,20 @@ describe.skip('Parse RDMD Callouts', () => { expect(tree.children[0].children[0].children[1].type).toBe('rdme-callout'); }); - it('does not require a line break between the title and the body', () => { + it('does require a line break between the title and the body', () => { const text = ` > đ Undocumented Behavior > Lorem ipsum dolor sit amet consectetur adipisicing elit.`; const tree = mdast(text); - expect(tree.children[0].data.hProperties.title).toBe( + expect(tree.children[0].children[0].children[0].value).toBe( `Undocumented Behavior -Lorem ipsum dolor sit amet consectetur adipisicing elit.` +Lorem ipsum dolor sit amet consectetur adipisicing elit.`, ); }); }); -describe.skip('emoji modifier support', () => { +describe('emoji modifier support', () => { const emojis = ['đ', 'đ§', 'â ī¸', 'đ', 'â ', 'âī¸', 'â', 'đ', 'âī¸', 'âŧī¸', 'âšī¸', 'â ']; emojis.forEach(emoji => { diff --git a/__tests__/transformers/callouts.test.ts b/__tests__/transformers/callouts.test.ts index d26ed61bf..51461f857 100644 --- a/__tests__/transformers/callouts.test.ts +++ b/__tests__/transformers/callouts.test.ts @@ -1,4 +1,4 @@ -import { mdast, hast } from '../../index'; +import { mdast } from '../../index'; describe('callouts transformer', () => { it('can parse callouts', () => { diff --git a/__tests__/transformers/readme-components.test.ts b/__tests__/transformers/readme-components.test.ts index 2adb51da0..edcdb97c1 100644 --- a/__tests__/transformers/readme-components.test.ts +++ b/__tests__/transformers/readme-components.test.ts @@ -18,7 +18,10 @@ describe('Readme Components Transformer', () => { const docs = { ['rdme-callout']: { md: `> đ It works!`, - mdx: `Callout with no title.
); }; diff --git a/docs/callout-tests.md b/docs/callout-tests.md index b36f63c6d..c0b0060ed 100644 --- a/docs/callout-tests.md +++ b/docs/callout-tests.md @@ -15,8 +15,10 @@ hidden: true > - was only rendering > - one child -{icon} - {!empty && heading} + {empty || children[0]}
- {body} + {empty ? children : React.Children.toArray(children).slice(1)}
& { hName: 'Callout'; hProperties: { icon: string; + empty: boolean; }; }; };