Skip to content

Commit

Permalink
feat: support nested container syntax in component in mdx-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Jan 15, 2025
1 parent 9583062 commit 674136e
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 46 deletions.
16 changes: 16 additions & 0 deletions e2e/fixtures/github-alert-mdxjs/doc/index.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Steps } from '@theme';

# Hello world

> [!TIP]
Expand Down Expand Up @@ -52,3 +54,17 @@
> [!WARNING]
> This is a 'warning' style block.
<Steps>
1. Title
> [!INFO]
> This is a 'info' style block.
- Title
> [!WARNING]
> This is a 'warning' style block.
</Steps>
16 changes: 16 additions & 0 deletions e2e/fixtures/github-alert-mdxrs/doc/index.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Steps } from '@theme';

# Hello world

> [!TIP]
Expand Down Expand Up @@ -52,3 +54,17 @@
> [!WARNING]
> This is a 'warning' style block.
<Steps>
1. Title
> [!INFO]
> This is a 'info' style block.
- Title
> [!WARNING]
> This is a 'warning' style block.
</Steps>
17 changes: 13 additions & 4 deletions e2e/tests/github-alert-mdxjs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@ test.describe('github alert syntax in mdx-js', async () => {
);
expect(listDirectives.length).toEqual(2);

const stepsDirectives = await page.$$(
'.rspress-doc > .\\[counter-reset\\:step\\] * > li > [class^="rspress-directive"]',
);
expect(stepsDirectives.length).toEqual(2);

const containerTypes = await Promise.all(
[...topLevelDirectives, ...listDirectives].map(async directive => {
const className = await directive.getAttribute('class');
return className?.split(' ')[1];
}),
[...topLevelDirectives, ...listDirectives, ...stepsDirectives].map(
async directive => {
const className = await directive.getAttribute('class');
return className?.split(' ')[1];
},
),
);
expect(containerTypes).toEqual([
'tip',
Expand All @@ -51,6 +58,8 @@ test.describe('github alert syntax in mdx-js', async () => {
'details',
'info',
'warning',
'info',
'warning',
]);
});
});
17 changes: 13 additions & 4 deletions e2e/tests/github-alert-mdxrs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@ test.describe('github alert syntax in mdx-rs', async () => {
);
expect(listDirectives.length).toEqual(2);

const stepsDirectives = await page.$$(
'.rspress-doc > .\\[counter-reset\\:step\\] * > li > [class^="rspress-directive"]',
);
expect(stepsDirectives.length).toEqual(2);

const containerTypes = await Promise.all(
[...topLevelDirectives, ...listDirectives].map(async directive => {
const className = await directive.getAttribute('class');
return className?.split(' ')[1];
}),
[...topLevelDirectives, ...listDirectives, ...stepsDirectives].map(
async directive => {
const className = await directive.getAttribute('class');
return className?.split(' ')[1];
},
),
);
expect(containerTypes).toEqual([
'tip',
Expand All @@ -51,6 +58,8 @@ test.describe('github alert syntax in mdx-rs', async () => {
'details',
'info',
'warning',
'info',
'warning',
]);
});
});
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@rsbuild/plugin-less": "~1.1.0",
"@rsbuild/plugin-react": "~1.1.0",
"@rsbuild/plugin-sass": "~1.1.2",
"@rspress/mdx-rs": "0.6.5",
"@rspress/mdx-rs": "0.6.6",
"@rspress/plugin-auto-nav-sidebar": "workspace:*",
"@rspress/plugin-container-syntax": "workspace:*",
"@rspress/plugin-last-updated": "workspace:*",
Expand Down
74 changes: 37 additions & 37 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 674136e

Please sign in to comment.