Skip to content

Commit 1599ced

Browse files
committed
ℹ Improve formatting of myst-to-md
1 parent 0363614 commit 1599ced

File tree

29 files changed

+501
-171
lines changed

29 files changed

+501
-171
lines changed

.changeset/cool-ducks-sing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"myst-parser": patch
3+
---
4+
5+
Add body/options to the mystDirective and mystRole nodes

.changeset/tender-pianos-cheat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"myst-to-md": patch
3+
---
4+
5+
Improve formatting of raw myst-directives

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/myst-ext-card/tests/card.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('card directive', () => {
1111
{
1212
type: 'mystDirective',
1313
name: 'card',
14-
args: 'Card Title',
14+
args: [{ type: 'text', value: 'Card Title' }],
1515
value: 'Header\n^^^\n\nCard content\n+++\nFooter',
1616
position: {
1717
start: {
@@ -142,7 +142,7 @@ describe('card directive', () => {
142142
const output = mystParse(content, {
143143
directives: [cardDirective],
144144
});
145-
expect(output).toEqual(expected);
145+
expect(output).toMatchObject(expected);
146146
});
147147
it('card directive parses with options', async () => {
148148
const content =
@@ -153,11 +153,11 @@ describe('card directive', () => {
153153
{
154154
type: 'mystDirective',
155155
name: 'card',
156-
args: 'Card Title',
156+
args: [{ type: 'text', value: 'Card Title' }],
157157
options: {
158-
header: 'Header',
159-
footer: 'Footer',
160-
link: 'my-url',
158+
header: [{ type: 'text', value: 'Header' }],
159+
footer: [{ type: 'text', value: 'Footer' }],
160+
url: 'my-url',
161161
},
162162
value: 'Card\n^^^\ncontent',
163163
position: {
@@ -280,7 +280,7 @@ describe('card directive', () => {
280280
const output = mystParse(content, {
281281
directives: [cardDirective],
282282
});
283-
expect(output).toEqual(expected);
283+
expect(output).toMatchObject(expected);
284284
});
285285
it('card directive parses with minimal content', async () => {
286286
const content = '```{card}\nCard content\n```';
@@ -343,7 +343,7 @@ describe('card directive', () => {
343343
const output = mystParse(content, {
344344
directives: [cardDirective],
345345
});
346-
expect(output).toEqual(expected);
346+
expect(output).toMatchObject(expected);
347347
});
348348
});
349349

packages/myst-ext-exercise/tests/exercise.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('exercise directive', () => {
2222
options: {
2323
label: 'ex-1',
2424
},
25-
args: 'Exercise Title',
25+
args: [{ type: 'text', value: 'Exercise Title' }],
2626
value: 'Exercise content',
2727
children: [
2828
{
@@ -58,7 +58,7 @@ describe('exercise directive', () => {
5858
const output = mystParse(content, {
5959
directives: [exerciseDirective],
6060
});
61-
expect(deletePositions(output)).toEqual(expected);
61+
expect(deletePositions(output)).toMatchObject(expected);
6262
});
6363
it('nonumber is prioritized over enumerated', async () => {
6464
const content =
@@ -74,7 +74,7 @@ describe('exercise directive', () => {
7474
enumerated: true,
7575
nonumber: true,
7676
},
77-
args: 'Exercise Title',
77+
args: [{ type: 'text', value: 'Exercise Title' }],
7878
value: 'Exercise content',
7979
children: [
8080
{
@@ -110,7 +110,7 @@ describe('exercise directive', () => {
110110
const output = mystParse(content, {
111111
directives: [exerciseDirective],
112112
});
113-
expect(deletePositions(output)).toEqual(expected);
113+
expect(deletePositions(output)).toMatchObject(expected);
114114
});
115115
it('exercises are enumerated with labels by default', async () => {
116116
const content = '```{exercise} Exercise Title\nExercise content\n```';
@@ -125,7 +125,7 @@ describe('exercise directive', () => {
125125
{
126126
type: 'mystDirective',
127127
name: 'exercise',
128-
args: 'Exercise Title',
128+
args: [{ type: 'text', value: 'Exercise Title' }],
129129
value: 'Exercise content',
130130
children: [
131131
{
@@ -158,6 +158,6 @@ describe('exercise directive', () => {
158158
},
159159
],
160160
};
161-
expect(deletePositions(output)).toEqual(expected);
161+
expect(deletePositions(output)).toMatchObject(expected);
162162
});
163163
});

packages/myst-ext-grid/tests/grid.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ describe('grid directive', () => {
8787
const output = mystParse(content, {
8888
directives: [gridDirective],
8989
});
90-
expect(output).toEqual(expected);
90+
expect(output).toMatchObject(expected);
9191
});
9292
});

packages/myst-ext-icon/tests/icon.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('icon role', () => {
4444
const output = mystParse(markup, {
4545
roles: [iconRole],
4646
});
47-
expect(deletePositions(output)).toEqual(expected);
47+
expect(deletePositions(output)).toMatchObject(expected);
4848
},
4949
);
5050
it.each(Object.entries(LEGACY_ICON_ALIASES))(
@@ -79,7 +79,7 @@ describe('icon role', () => {
7979
const output = mystParse(markup, {
8080
roles: [iconRole],
8181
});
82-
expect(deletePositions(output)).toEqual(expected);
82+
expect(deletePositions(output)).toMatchObject(expected);
8383
},
8484
);
8585
});

packages/myst-ext-proof/tests/proof.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('proof directive', () => {
1111
{
1212
type: 'mystDirective',
1313
name: 'prf:proof',
14-
args: 'Proof Title',
14+
args: [{ type: 'text', value: 'Proof Title' }],
1515
value: 'Proof content',
1616
position: {
1717
start: {
@@ -86,6 +86,6 @@ describe('proof directive', () => {
8686
const output = mystParse(content, {
8787
directives: [proofDirective],
8888
});
89-
expect(output).toEqual(expected);
89+
expect(output).toMatchObject(expected);
9090
});
9191
});

packages/myst-ext-reactive/tests/reactive.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('reactive tests', () => {
4141
roles: [reactiveRole],
4242
directives: [reactiveDirective],
4343
});
44-
expect(output).toEqual(expected);
44+
expect(output).toMatchObject(expected);
4545
});
4646
it('r:dynamic role parses', async () => {
4747
const content = '{r:dynamic}`rValue="visitors", rChange="{visitors: value}", value="5"`';
@@ -92,6 +92,6 @@ describe('reactive tests', () => {
9292
roles: [reactiveRole],
9393
directives: [reactiveDirective],
9494
});
95-
expect(output).toEqual(expected);
95+
expect(output).toMatchObject(expected);
9696
});
9797
});

packages/myst-ext-tabs/tests/tabs.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('tab directives', () => {
3131
const output = mystParse(content, {
3232
directives: [...tabDirectives],
3333
});
34-
expect(deletePositions(output)).toEqual(expected);
34+
expect(deletePositions(output)).toMatchObject(expected);
3535
});
3636
it('tabSet class option parses', async () => {
3737
const content = '```{tab-set}\n:class: my-class\n```';
@@ -57,7 +57,7 @@ describe('tab directives', () => {
5757
const output = mystParse(content, {
5858
directives: [...tabDirectives],
5959
});
60-
expect(deletePositions(output)).toEqual(expected);
60+
expect(deletePositions(output)).toMatchObject(expected);
6161
});
6262
it.each(['tab-item', 'tabItem'])('%s with title parses', async (name: string) => {
6363
const content = `\`\`\`{${name}} Tab One\n\`\`\``;
@@ -81,7 +81,7 @@ describe('tab directives', () => {
8181
const output = mystParse(content, {
8282
directives: [...tabDirectives],
8383
});
84-
expect(deletePositions(output)).toEqual(expected);
84+
expect(deletePositions(output)).toMatchObject(expected);
8585
});
8686
it('tabItem sync and selected options parse', async () => {
8787
const content = '```{tab-item} Tab One\n:sync: tab1\n:selected:\n```';
@@ -111,7 +111,7 @@ describe('tab directives', () => {
111111
const output = mystParse(content, {
112112
directives: [...tabDirectives],
113113
});
114-
expect(deletePositions(output)).toEqual(expected);
114+
expect(deletePositions(output)).toMatchObject(expected);
115115
});
116116
// TODO: enable when we have a better required/fallback/default pattern
117117
it.skip('tabItem without title errors', async () => {
@@ -202,6 +202,6 @@ describe('tab directives', () => {
202202
const output = mystParse(content, {
203203
directives: [...tabDirectives],
204204
});
205-
expect(deletePositions(output)).toEqual(expected);
205+
expect(deletePositions(output)).toMatchObject(expected);
206206
});
207207
});

0 commit comments

Comments
 (0)