-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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 <[email protected]> Co-authored-by: Joshua Chen <[email protected]> Co-authored-by: sebastienlorber <[email protected]> Co-authored-by: Sébastien Lorber <[email protected]> Co-authored-by: LittleboyHarry <[email protected]> Co-authored-by: Mikey O'Toole <[email protected]> Co-authored-by: Jan Peer Stöcklmair <[email protected]> Co-authored-by: Nguyễn Thành Nam <[email protected]> Co-authored-by: Sanjaiyan Parthipan <[email protected]> Co-authored-by: Ramazan SANCAR <[email protected]> Co-authored-by: mturoci <[email protected]> Co-authored-by: Adnan Hashmi <[email protected]> Co-authored-by: Pranav Joglekar <[email protected]> Co-authored-by: forgeRW <[email protected]> Co-authored-by: Masahiko Hara <[email protected]> Co-authored-by: Johan Fagerberg <[email protected]> Co-authored-by: John Reilly <[email protected]> Co-authored-by: Sam Wall <[email protected]> Co-authored-by: Jeferson S. Brito <[email protected]> Co-authored-by: evan <[email protected]> Co-authored-by: Xabier Lahuerta Vazquez <[email protected]> Co-authored-by: Forresst <[email protected]> Co-authored-by: Shanmughapriyan S <[email protected]> Co-authored-by: Alexey Pyltsyn <[email protected]>
- 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.