-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: backport retro compatible commits for the Docusaurus v2.2 rele…
…ase (#8264) Co-authored-by: Jan Peer Stoecklmair <jan.peer.stoecklmair@dynatrace.com> Co-authored-by: Joshua Chen <sidachen2003@gmail.com> Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com> Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com> Co-authored-by: LittleboyHarry <littleboyharry@qq.com> Co-authored-by: Mikey O'Toole <mikey@homotechsual.dev> Co-authored-by: Jan Peer Stöcklmair <jan.oster94@gmail.com> Co-authored-by: Nguyễn Thành Nam <namnguyenthanh.work@gmail.com> Co-authored-by: Sanjaiyan Parthipan <parthipankalayini@gmail.com> Co-authored-by: Ramazan SANCAR <ramazansancar4545@gmail.com> Co-authored-by: mturoci <64769322+mturoci@users.noreply.github.com> Co-authored-by: Adnan Hashmi <56730784+adnanhashmi09@users.noreply.github.com> Co-authored-by: Pranav Joglekar <pranav2000joglekar@gmail.com> Co-authored-by: forgeRW <20483211+forgeRW@users.noreply.github.com> Co-authored-by: Masahiko Hara <pasora@sfc.wide.ad.jp> Co-authored-by: Johan Fagerberg <johanringmann@gmail.com> Co-authored-by: John Reilly <johnny_reilly@hotmail.com> Co-authored-by: Sam Wall <oss@samuelwall.co.uk> Co-authored-by: Jeferson S. Brito <30840709+jeferson-sb@users.noreply.github.com> Co-authored-by: evan <evanmccarthy@outlook.com> Co-authored-by: Xabier Lahuerta Vazquez <xlahuerta@protonmail.com> Co-authored-by: Forresst <forresst17@gmail.com> Co-authored-by: Shanmughapriyan S <priyanshan03@gmail.com> Co-authored-by: Alexey Pyltsyn <lex61rus@gmail.com>
- Loading branch information
1 parent
7743aa6
commit de97214
Showing
155 changed files
with
2,820 additions
and
561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"npmClient": "yarn", | ||
"useWorkspaces": true, | ||
"changelog": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/docusaurus-mdx-loader/src/remark/mermaid/__tests__/__snapshots__/index.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`mermaid remark plugin does nothing if there's no mermaid code block 1`] = ` | ||
" | ||
const layoutProps = { | ||
}; | ||
const MDXLayout = "wrapper" | ||
export default function MDXContent({ | ||
components, | ||
...props | ||
}) { | ||
return <MDXLayout {...layoutProps} {...props} components={components} mdxType="MDXLayout"> | ||
<h1>{\`Heading 1\`}</h1> | ||
<p>{\`No Mermaid diagram :(\`}</p> | ||
<pre><code parentName="pre" {...{ | ||
"className": "language-js" | ||
}}>{\`this is not mermaid | ||
\`}</code></pre> | ||
</MDXLayout>; | ||
} | ||
; | ||
MDXContent.isMDXComponent = true;" | ||
`; | ||
exports[`mermaid remark plugin works for basic mermaid code blocks 1`] = ` | ||
" | ||
const layoutProps = { | ||
}; | ||
const MDXLayout = "wrapper" | ||
export default function MDXContent({ | ||
components, | ||
...props | ||
}) { | ||
return <MDXLayout {...layoutProps} {...props} components={components} mdxType="MDXLayout"> | ||
<h1>{\`Heading 1\`}</h1> | ||
<mermaid {...{ | ||
"value": "graph TD;/n A-->B;/n A-->C;/n B-->D;/n C-->D;" | ||
}}></mermaid> | ||
</MDXLayout>; | ||
} | ||
; | ||
MDXContent.isMDXComponent = true;" | ||
`; |
46 changes: 46 additions & 0 deletions
46
packages/docusaurus-mdx-loader/src/remark/mermaid/__tests__/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {createCompiler} from '@mdx-js/mdx'; | ||
import mermaid from '..'; | ||
|
||
describe('mermaid remark plugin', () => { | ||
function createTestCompiler() { | ||
return createCompiler({ | ||
remarkPlugins: [mermaid], | ||
}); | ||
} | ||
|
||
it("does nothing if there's no mermaid code block", async () => { | ||
const mdxCompiler = createTestCompiler(); | ||
const result = await mdxCompiler.process( | ||
`# Heading 1 | ||
No Mermaid diagram :( | ||
\`\`\`js | ||
this is not mermaid | ||
\`\`\` | ||
`, | ||
); | ||
expect(result.contents).toMatchSnapshot(); | ||
}); | ||
|
||
it('works for basic mermaid code blocks', async () => { | ||
const mdxCompiler = createTestCompiler(); | ||
const result = await mdxCompiler.process(`# Heading 1 | ||
\`\`\`mermaid | ||
graph TD; | ||
A-->B; | ||
A-->C; | ||
B-->D; | ||
C-->D; | ||
\`\`\``); | ||
expect(result.contents).toMatchSnapshot(); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
packages/docusaurus-mdx-loader/src/remark/mermaid/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import visit from 'unist-util-visit'; | ||
import type {Transformer} from 'unified'; | ||
import type {Code} from 'mdast'; | ||
|
||
// TODO: this plugin shouldn't be in the core MDX loader | ||
// After we allow plugins to provide Remark/Rehype plugins (see | ||
// https://github.com/facebook/docusaurus/issues/6370), this should be provided | ||
// by theme-mermaid itself | ||
export default function plugin(): Transformer { | ||
return (root) => { | ||
visit(root, 'code', (node: Code, index, parent) => { | ||
if (node.lang === 'mermaid') { | ||
parent!.children.splice(index, 1, { | ||
type: 'mermaidCodeBlock', | ||
data: { | ||
hName: 'mermaid', | ||
hProperties: { | ||
value: node.value, | ||
}, | ||
}, | ||
}); | ||
} | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.