-
Notifications
You must be signed in to change notification settings - Fork 142
Add Mermaid Plugin #2475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Mermaid Plugin #2475
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
a9a873b
Add mermaid plugin
Tim-Siu a22da8e
Improve code quality
Tim-Siu 968378b
Improve code quality
Tim-Siu a818c5c
Merge branch 'master' into mermaid
Tim-Siu 5baf061
Add unit test
Tim-Siu 1d48418
Add functional test
Tim-Siu 3b19e31
Add documentation
Tim-Siu 1f9a752
Enhance functional test with inside panel option
Tim-Siu 6358354
Update test expected
Tim-Siu fa53f12
Merge branch 'master' into mermaid
Tim-Siu e7d6d4d
Improve documentation
Tim-Siu fb21d00
Merge master
Tim-Siu 6658892
Fix code issues
Tim-Siu 713a4d1
Update functional code
Tim-Siu 0736424
Update unit test
Tim-Siu c2fa86c
Merge branch 'master' into mermaid
Tim-Siu edc199a
Merge branch 'master' into mermaid
Tim-Siu c4bfb0c
Merge branch 'master' into mermaid
Tim-Siu 0577836
Switch to Async loading of script
Tim-Siu 226f503
Update testcases
Tim-Siu 5803613
Update testcases
Tim-Siu 6a0f331
Fix broken link
Tim-Siu a3ac59d
Merge branch 'master' into mermaid
Tim-Siu 10441c0
Polish documentation
Tim-Siu 1d3cf98
Revert async loading of mermaid script
Tim-Siu a63d674
Update functional test
Tim-Siu fc6da44
Update functional test
Tim-Siu f5d0c0a
Improve documentation
Tim-Siu c0a1488
Enhance functional test to cover inclusion
Tim-Siu 3186303
Update expected
Tim-Siu 3265bb7
Minor update to syntax
Tim-Siu 6df7858
Update functional test
Tim-Siu fd2c69c
Merge branch 'master' into mermaid
Tim-Siu 2bf16fe
Fix typo
Tim-Siu ca91a02
Fix typo
Tim-Siu 392b756
Fix nits
yucheng11122017 c6c869b
fix nits
yucheng11122017 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,112 @@ | ||
| ### Plugin: Mermaid | ||
|
|
||
| <div id="content"> | ||
|
|
||
| This plugin allows you to utilize [Mermaid](https://mermaid-js.github.io/mermaid/) by automatically importing the library and initializing the rendering of the diagrams. | ||
|
|
||
| > Mermaid is a JavaScript based diagramming and charting tool that renders Markdown-inspired text definitions to create and modify diagrams dynamically. | ||
|
|
||
| <box type="info"> | ||
|
|
||
| All supported diagrams are available in [the Mermaid official documentation](https://mermaid-js.github.io/mermaid/). | ||
|
|
||
| </box> | ||
|
|
||
| To enable this plugin, add `mermaid` to your site's plugins. | ||
|
|
||
| ```js {heading="site.json"} | ||
| { | ||
| ... | ||
| "plugins": [ | ||
| "mermaid" | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| <panel header="Optional: Specify an alternative URL to load the Mermaid code"> | ||
|
|
||
| By default, the plugin loads the Mermaid code from a CDN URL. However, you can optionally specify an alternative URL to load the Mermaid code from a different source. | ||
|
|
||
| ```js {heading="site.json"} | ||
| { | ||
| ... | ||
| "plugins": [ | ||
| "mermaid" | ||
| ], | ||
| "pluginsContext": { | ||
| "mermaid": { | ||
| "address": "https://unpkg.com/mermaid@10/dist/mermaid.esm.min.mjs" // replace with URL of your choice | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| </panel> | ||
|
|
||
| To create a Mermaid diagram, use the `<mermaid>` tag and provide the diagram definition within the tag. | ||
|
|
||
| {{ icon_example }} Pie Chart: | ||
|
|
||
| <include src="codeAndOutput.md" boilerplate > | ||
| <variable name="highlightStyle">html</variable> | ||
| <variable name="code"> | ||
| <mermaid> | ||
| pie title Pets adopted by volunteers | ||
| "Dogs" : 386 | ||
| "Cats" : 85 | ||
| "Rats" : 15 | ||
| </mermaid> | ||
| </variable> | ||
| </include> | ||
|
|
||
| {{ icon_example }} Flowchart: | ||
|
|
||
| <include src="codeAndOutput.md" boilerplate > | ||
| <variable name="highlightStyle">html</variable> | ||
| <variable name="code"> | ||
| <mermaid> | ||
| flowchart TD | ||
| A[Start] --> B{Is it?} | ||
| B -->|Yes| C[OK] | ||
| C --> D[Rethink] | ||
| D --> B | ||
| B ---->|No| E[End] | ||
| </mermaid> | ||
| </variable> | ||
| </include> | ||
|
|
||
| {{ icon_example }} User Journey Diagram: | ||
|
|
||
| <include src="codeAndOutput.md" boilerplate > | ||
| <variable name="highlightStyle">html</variable> | ||
| <variable name="code"> | ||
| <mermaid> | ||
| journey | ||
| title My working day | ||
| section Go to work | ||
| Make tea: 5: Me | ||
| Go upstairs: 3: Me | ||
| Do work: 1: Me, Cat | ||
| </mermaid> | ||
| </variable> | ||
| </include> | ||
|
|
||
| {{ icon_example }} Gitgraph Diagram: | ||
|
|
||
| <include src="codeAndOutput.md" boilerplate > | ||
| <variable name="highlightStyle">html</variable> | ||
| <variable name="code"> | ||
| <mermaid> | ||
| gitGraph | ||
| commit | ||
| branch develop | ||
| checkout develop | ||
| commit | ||
| checkout main | ||
| merge develop | ||
| </mermaid> | ||
| </variable> | ||
| </include> | ||
|
|
||
| The plugin automatically converts the `<mermaid>` tags into appropriate `<div>` elements with the necessary classes and attributes for rendering the diagrams using the Mermaid library. | ||
| <div> | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -65,6 +65,7 @@ MarkBind has a set of built-in plugins that can be used immediately without inst | |
| <include src="plugins/mathDelimiters.md" /> | ||
| <include src="plugins/web3Form.md" /> | ||
| <include src="plugins/dataTable.md" /> | ||
| <include src="plugins/mermaid.md" /> | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary new line |
||
| ## Using External Plugins | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.