Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit dd4a940

Browse files
committed
feat(mdx-loader): add mermaid attr
1 parent 394bf3d commit dd4a940

File tree

4 files changed

+76
-3
lines changed

4 files changed

+76
-3
lines changed

packages/mdx-loader/__tests__/__snapshots__/index.js.snap

+56
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,62 @@ export default function MDXContent({
960960
MDXContent.isMDXComponent = true;"
961961
`;
962962

963+
exports[`fusuma-loader should convert mermaid using mermaid attr 1`] = `
964+
"/* @jsxRuntime classic */
965+
/* @jsx mdx */
966+
967+
import React from 'react';
968+
import { mdx } from '@mdx-js/react';
969+
export const slides = [props => <>
970+
971+
<h1>{\`FlowChart\`}</h1>
972+
973+
</>, props => <>
974+
975+
<div className=\\"mermaid\\" id=\\"mermaid-1\\" data-value=\\"graph TD;
976+
A-->B;
977+
A-->C;
978+
B-->D;
979+
C-->D;\\" style={{
980+
visibility: 'hidden'
981+
}}>graph TD;
982+
A-->B;
983+
A-->C;
984+
B-->D;
985+
C-->D;</div>
986+
987+
</>];
988+
export const backgrounds = [0, 0];
989+
export const fragmentSteps = [0, 0];
990+
export const fusumaProps = [{}, {}];
991+
992+
const layoutProps = {
993+
994+
};
995+
const MDXLayout = \\"wrapper\\"
996+
export default function MDXContent({
997+
components,
998+
...props
999+
}) {
1000+
return <MDXLayout {...layoutProps} {...props} components={components} mdxType=\\"MDXLayout\\">
1001+
<h1>{\`FlowChart\`}</h1>
1002+
<hr></hr>
1003+
<pre><code parentName=\\"pre\\" {...{
1004+
\\"className\\": \\"language-mermaid\\"
1005+
}}>{\`graph TD;
1006+
A-->B;
1007+
A-->C;
1008+
B-->D;
1009+
C-->D;
1010+
\`}</code></pre>
1011+
1012+
</MDXLayout>;
1013+
}
1014+
1015+
;
1016+
MDXContent.isMDXComponent = true;"
1017+
`;
1018+
9631019
exports[`fusuma-loader should return normal md 1`] = `
9641020
"/* @jsxRuntime classic */
9651021
/* @jsx mdx */

packages/mdx-loader/__tests__/index.js

+17
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ graph TD;
9393
expect(await transformToJS(src)).toMatchSnapshot();
9494
});
9595

96+
test('should convert mermaid using mermaid attr', async () => {
97+
const src = `
98+
# FlowChart
99+
---
100+
101+
\`\`\`mermaid
102+
graph TD;
103+
A-->B;
104+
A-->C;
105+
B-->D;
106+
C-->D;
107+
\`\`\`
108+
`;
109+
110+
expect(await transformToJS(src)).toMatchSnapshot();
111+
});
112+
96113
test('should convert MathJax', async () => {
97114
const src = `
98115
# MathJax

packages/mdx-loader/src/mdxPlugin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function mdxPlugin() {
148148
}
149149

150150
if (type === 'code') {
151-
if (lang === 'chart') {
151+
if (lang === 'chart' || lang === 'mermaid') {
152152
slide.push({
153153
...n,
154154
...transformChartToJSX(mermaidId, value),

samples/advanced/slides/01-chart.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<br />
66

7-
```chart
7+
```mermaid
88
graph TD;
99
A-->B;
1010
A-->C;
@@ -21,7 +21,7 @@ https://github.com/knsv/mermaid
2121
<br />
2222

2323
```txt
24-
\`\`\`chart
24+
\`\`\`mermaid
2525
graph TD;
2626
A-->B;
2727
A-->C;

0 commit comments

Comments
 (0)