From 65c93807d8204f81c44f47a8bb736f734f0a53a6 Mon Sep 17 00:00:00 2001 From: "Nicko J. Ruddock" Date: Fri, 11 Aug 2023 15:23:16 +0100 Subject: [PATCH 01/70] Fix Twitter fontawesome class in flowchart.md --- packages/mermaid/src/docs/syntax/flowchart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/docs/syntax/flowchart.md b/packages/mermaid/src/docs/syntax/flowchart.md index 56cad19a0..7418b96e0 100644 --- a/packages/mermaid/src/docs/syntax/flowchart.md +++ b/packages/mermaid/src/docs/syntax/flowchart.md @@ -728,7 +728,7 @@ The icons are accessed via the syntax fa:#icon class name#. ```mermaid-example flowchart TD - B["fab:fa-twitter for peace"] + B["fa:fa-twitter for peace"] B-->C[fa:fa-ban forbidden] B-->D(fa:fa-spinner) B-->E(A fa:fa-camera-retro perhaps?) From 341130856f04be7266d9385c9546c3beeacb79f8 Mon Sep 17 00:00:00 2001 From: Nikolay Rozhkov Date: Thu, 17 Aug 2023 23:52:56 +0300 Subject: [PATCH 02/70] Split development documentation in several separate pages, fixes for the sidebar menu United similar sections at the intro page Fix spelling Update docs --- README.md | 2 +- README.zh-CN.md | 2 +- cSpell.json | 1 + docs/community/code.md | 176 ++++++++ docs/community/development.md | 399 +++--------------- docs/community/docker-development.md | 109 +++++ docs/community/documentation.md | 106 +++++ docs/community/n00b-overview.md | 74 ---- docs/community/questionsAndSuggestions.md | 28 ++ docs/intro/index.md | 35 +- docs/intro/n00b-syntaxReference.md | 4 +- .../mermaid/src/docs/.vitepress/config.ts | 52 +-- .../src/docs/.vitepress/theme/redirect.ts | 1 + packages/mermaid/src/docs/community/code.md | 165 ++++++++ .../mermaid/src/docs/community/development.md | 387 +++-------------- .../src/docs/community/docker-development.md | 104 +++++ .../src/docs/community/documentation.md | 93 ++++ .../src/docs/community/n00b-overview.md | 68 --- .../docs/community/questionsAndSuggestions.md | 22 + packages/mermaid/src/docs/intro/index.md | 35 +- .../src/docs/intro/n00b-syntaxReference.md | 4 +- run | 3 + 22 files changed, 953 insertions(+), 917 deletions(-) create mode 100644 docs/community/code.md create mode 100644 docs/community/docker-development.md create mode 100644 docs/community/documentation.md delete mode 100644 docs/community/n00b-overview.md create mode 100644 docs/community/questionsAndSuggestions.md create mode 100644 packages/mermaid/src/docs/community/code.md create mode 100644 packages/mermaid/src/docs/community/docker-development.md create mode 100644 packages/mermaid/src/docs/community/documentation.md delete mode 100644 packages/mermaid/src/docs/community/n00b-overview.md create mode 100644 packages/mermaid/src/docs/community/questionsAndSuggestions.md diff --git a/README.md b/README.md index bdffbe175..0f47ceca2 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Use Mermaid with your favorite applications, check out the list of [Integrations You can also use Mermaid within [GitHub](https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid/) as well many of your other favorite applications—check out the list of [Integrations and Usages of Mermaid](./docs/ecosystem/integrations.md). -For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](./docs/community/n00b-overview.md), [Usage](./docs/config/usage.md) and [Tutorials](./docs/config/Tutorials.md). +For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](./docs/intro/n00b-gettingStarted.md), [Usage](./docs/config/usage.md) and [Tutorials](./docs/config/Tutorials.md). In our release process we rely heavily on visual regression tests using [applitools](https://applitools.com/). Applitools is a great service which has been easy to use and integrate with our tests. diff --git a/README.zh-CN.md b/README.zh-CN.md index 9a2e797be..0cc05906e 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -55,7 +55,7 @@ Mermaid 通过允许用户创建便于修改的图表来解决这一难题,它 Mermaid 甚至能让非程序员也能通过 [Mermaid Live Editor](https://mermaid.live/) 轻松创建详细的图表。
你可以访问 [教程](./docs/config/Tutorials.md) 来查看 Live Editor 的视频教程,也可以查看 [Mermaid 的集成和使用](./docs/ecosystem/integrations.md) 这个清单来检查你的文档工具是否已经集成了 Mermaid 支持。 -如果想要查看关于 Mermaid 更详细的介绍及基础使用方式,可以查看 [入门指引](./docs/community/n00b-overview.md), [用法](./docs/config/usage.md) 和 [教程](./docs/config/Tutorials.md). +如果想要查看关于 Mermaid 更详细的介绍及基础使用方式,可以查看 [入门指引](./docs/intro/n00b-gettingStarted.md), [用法](./docs/config/usage.md) 和 [教程](./docs/config/Tutorials.md). diff --git a/cSpell.json b/cSpell.json index af7a9ca46..055c4b20b 100644 --- a/cSpell.json +++ b/cSpell.json @@ -91,6 +91,7 @@ "nextra", "nikolay", "nirname", + "npmjs", "orlandoni", "pathe", "pbrolin", diff --git a/docs/community/code.md b/docs/community/code.md new file mode 100644 index 000000000..7f4b1e105 --- /dev/null +++ b/docs/community/code.md @@ -0,0 +1,176 @@ +> **Warning** +> +> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. +> +> ## Please edit the corresponding file in [/packages/mermaid/src/docs/community/code.md](../../packages/mermaid/src/docs/community/code.md). + +# Contributing Code + +The basic steps for contributing code are: + +```mermaid-example +graph LR + git[1. Checkout a git branch] --> codeTest[2. Write tests and code] --> doc[3. Update documentation] --> submit[4. Submit a PR] --> review[5. Review and merge] +``` + +```mermaid +graph LR + git[1. Checkout a git branch] --> codeTest[2. Write tests and code] --> doc[3. Update documentation] --> submit[4. Submit a PR] --> review[5. Review and merge] +``` + +1. **Create** and checkout a git branch and work on your code in the branch +2. Write and update **tests** (unit and perhaps even integration (e2e) tests) (If you do TDD/BDD, the order might be different.) +3. **Let users know** that things have changed or been added in the documents! This is often overlooked, but _critical_ +4. **Submit** your code as a _pull request_. +5. Maintainers will **review** your code. If there are no changes necessary, the PR will be merged. Otherwise, make the requested changes and repeat. + +## 1. Checkout a git branch + +Mermaid uses a [Git Flow](https://guides.github.com/introduction/flow/)–inspired approach to branching. + +Development is done in the `develop` branch. + +Once development is done we create a `release/vX.X.X` branch from `develop` for testing. + +Once the release happens we add a tag to the `release` branch and merge it with `master`. The live product and on-line documentation are what is in the `master` branch. + +**All new work should be based on the `develop` branch.** + +**When you are ready to do work, always, ALWAYS:** + +1. Make sure you have the most up-to-date version of the `develop` branch. (fetch or pull to update it) +2. Check out the `develop` branch +3. Create a new branch for your work. Please name the branch following our naming convention below. + +We use the follow naming convention for branches: + +```txt + [feature | bug | chore | docs]/[issue number]_[short description using dashes ('-') or underscores ('_') instead of spaces] +``` + +You can always check current [configuration of labelling and branch prefixes](https://github.com/mermaid-js/mermaid/blob/develop/.github/pr-labeler.yml) + +- The first part is the **type** of change: a feature, bug, chore, or documentation change ('docs') +- followed by a _slash_ (which helps to group like types together in many git tools) +- followed by the **issue number** +- followed by an _underscore_ ('\_') +- followed by a short text description (but use dashes ('-') or underscores ('\_') instead of spaces) + +If your work is specific to a single diagram type, it is a good idea to put the diagram type at the start of the description. This will help us keep release notes organized: it will help us keep changes for a diagram type together. + +**Ex: A new feature described in issue 2945 that adds a new arrow type called 'florbs' to state diagrams** + +`feature/2945_state-diagram-new-arrow-florbs` + +**Ex: A bug described in issue 1123 that causes random ugly red text in multiple diagram types** +`bug/1123_fix_random_ugly_red_text` + +## 2. Write Tests + +Tests ensure that each function, module, or part of code does what it says it will do. This is critically +important when other changes are made to ensure that existing code is not broken (no regression). + +Just as important, the tests act as _specifications:_ they specify what the code does (or should do). +Whenever someone is new to a section of code, they should be able to read the tests to get a thorough understanding of what it does and why. + +If you are fixing a bug, you should add tests to ensure that your code has actually fixed the bug, to specify/describe what the code is doing, and to ensure the bug doesn't happen again. +(If there had been a test for the situation, the bug never would have happened in the first place.) +You may need to change existing tests if they were inaccurate. + +If you are adding a feature, you will definitely need to add tests. Depending on the size of your feature, you may need to add integration tests. + +### Unit Tests + +Unit tests are tests that test a single function or module. They are the easiest to write and the fastest to run. + +Unit tests are mandatory all code except the renderers. (The renderers are tested with integration tests.) + +We use [Vitest](https://vitest.dev) to run unit tests. + +You can use the following command to run the unit tests: + +```sh +pnpm test +``` + +When writing new tests, it's easier to have the tests automatically run as you make changes. You can do this by running the following command: + +```sh +pnpm test:watch +``` + +### Integration/End-to-End (e2e) tests + +These test the rendering and visual appearance of the diagrams. +This ensures that the rendering of that feature in the e2e will be reviewed in the release process going forward. Less chance that it breaks! + +To start working with the e2e tests: + +1. Run `pnpm dev` to start the dev server +2. Start **Cypress** by running `pnpm cypress:open`. + +The rendering tests are very straightforward to create. There is a function `imgSnapshotTest`, which takes a diagram in text form and the mermaid options, and it renders that diagram in Cypress. + +When running in CI it will take a snapshot of the rendered diagram and compare it with the snapshot from last build and flag it for review if it differs. + +This is what a rendering test looks like: + +```js +it('should render forks and joins', () => { + imgSnapshotTest( + ` + stateDiagram + state fork_state <<fork>> + [*] --> fork_state + fork_state --> State2 + fork_state --> State3 + + state join_state <<join>> + State2 --> join_state + State3 --> join_state + join_state --> State4 + State4 --> [*] + `, + { logLevel: 0 } + ); + cy.get('svg'); +}); +``` + +**_\[TODO - running the tests against what is expected in development. ]_** + +**_\[TODO - how to generate new screenshots]_** +.... + +## 3. Update Documentation + +If the users have no way to know that things have changed, then you haven't really _fixed_ anything for the users; you've just added to making Mermaid feel broken. +Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused. + +The documentation has to be updated to users know that things have changed and added! +If you are adding a new feature, add `(v+)` in the title or description. It will be replaced automatically with the current version number when the release happens. + +eg: `# Feature Name (v+)` + +We know it can sometimes be hard to code _and_ write user documentation. + +Our documentation is managed in `packages/mermaid/src/docs`. Details on how to edit is in the [Contributing Documentation](#contributing-documentation) section. + +Create another issue specifically for the documentation.\ +You will need to help with the PR, but definitely ask for help if you feel stuck. +When it feels hard to write stuff out, explaining it to someone and having that person ask you clarifying questions can often be 80% of the work! + +When in doubt, write up and submit what you can. It can be clarified and refined later. (With documentation, something is better than nothing!) + +## 4. Submit your pull request + +**\[TODO - PR titles should start with (fix | feat | ....)]** + +We make all changes via Pull Requests (PRs). As we have many Pull Requests from developers new to Mermaid, we have put in place a process wherein _knsv, Knut Sveidqvist_ is in charge of the final release process and the active maintainers are in charge of reviewing and merging most PRs. + +- PRs will be reviewed by active maintainers, who will provide feedback and request changes as needed. +- The maintainers will request a review from knsv, if necessary. +- Once the PR is approved, the maintainers will merge the PR into the `develop` branch. +- When a release is ready, the `release/x.x.x` branch will be created, extensively tested and knsv will be in charge of the release process. + +**Reminder: Pull Requests should be submitted to the develop branch.** diff --git a/docs/community/development.md b/docs/community/development.md index f8c8b0638..65ee18660 100644 --- a/docs/community/development.md +++ b/docs/community/development.md @@ -6,15 +6,9 @@ # Contributing to Mermaid -## Contents - -- [Technical Requirements and Setup](#technical-requirements-and-setup) -- [Contributing Code](#contributing-code) -- [Contributing Documentation](#contributing-documentation) -- [Questions or Suggestions?](#questions-or-suggestions) -- [Last Words](#last-words) - ---- +> The following documentation describes how to work with Mermaid in your host environment. +> There's also a [Docker installation guide](../community/docker-development.md) +> if you prefer to work in a Docker environment. So you want to help? That's great! @@ -22,47 +16,68 @@ So you want to help? That's great! Here are a few things to get you started on the right path. -## Technical Requirements and Setup +## Get the Source Code -### Technical Requirements +In GitHub, you first **fork** a repository when you are going to make changes and submit pull requests. -These are the tools we use for working with the code and documentation. +Then you **clone** a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with. + +[Fork mermaid](https://github.com/mermaid-js/mermaid/fork) to start contributing to the main project and its documentaion, or [search for other repositories](https://github.com/orgs/mermaid-js/repositories). + +[Here is a GitHub document that gives an overview of the process.](https://docs.github.com/en/get-started/quickstart/fork-a-repo) + +## Technical Requirements + +> The following documentation describes how to work with Mermaid in your host environment. +> There's also a [Docker installation guide](../community/docker-development.md) +> if you prefer to work in a Docker environment. + +These are the tools we use for working with the code and documentation: - [volta](https://volta.sh/) to manage node versions. - [Node.js](https://nodejs.org/en/). `volta install node` - [pnpm](https://pnpm.io/) package manager. `volta install pnpm` -- [npx](https://docs.npmjs.com/cli/v8/commands/npx) the packaged executor in npm. This is needed [to install pnpm.](#2-install-pnpm) +- [npx](https://docs.npmjs.com/cli/v8/commands/npx) the packaged executor in npm. This is needed [to install pnpm.](#install-packages) -Follow [the setup steps below](#setup) to install them and verify they are working +Follow the setup steps below to install them and start the development. -### Setup +## Setup and Launch -Follow these steps to set up the environment you need to work on code and/or documentation. +### Switch to project -#### 1. Fork and clone the repository - -In GitHub, you first _fork_ a repository when you are going to make changes and submit pull requests. - -Then you _clone_ a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with. - -[Here is a GitHub document that gives an overview of the process.](https://docs.github.com/en/get-started/quickstart/fork-a-repo) - -#### 2. Install pnpm - -Once you have cloned the repository onto your development machine, change into the `mermaid` project folder so that you can install `pnpm`. You will need `npx` to install pnpm because volta doesn't support it yet. - -Ex: +Once you have cloned the repository onto your development machine, change into the `mermaid` project folder (the top level directory of the mermaid project repository) ```bash -# Change into the mermaid directory (the top level director of the mermaid project repository) cd mermaid -# npx is required for first install because volta does not support pnpm yet -npx pnpm install ``` -#### 3. Verify Everything Is Working +### Install packages -Once you have installed pnpm, you can run the `test` script to verify that pnpm is working _and_ that the repository has been cloned correctly: +Run `npx pnpm install`. You will need `npx` for this because volta doesn't support it yet. + +```bash +npx pnpm install # npx is required for first install +``` + +### Launch + +```bash +npx pnpm run dev +``` + +Now you are ready to make your changes! Edit whichever files in `src` as required. + +Open in your browser, after starting the dev server. +There is a list of demos that can be used to see and test your changes. + +If you need a specific diagram, you can duplicate the `example.html` file in `/demos/dev` and add your own mermaid code to your copy. + +That will be served at . +After making code changes, the dev server will rebuild the mermaid library. You will need to reload the browser page yourself to see the changes. (PRs for auto reload are welcome!) + +## Verify Everything is Working + +You can run the `test` script to verify that pnpm is working _and_ that the repository has been cloned correctly: ```bash pnpm test @@ -70,321 +85,7 @@ pnpm test The `test` script and others are in the top-level `package.json` file. -All tests should run successfully without any errors or failures. (You might see _lint_ or _formatting_ "warnings"; those are ok during this step.) - -#### 4. Make your changes - -Now you are ready to make your changes! -Edit whichever files in `src` as required. - -#### 5. See your changes - -Open in your browser, after starting the dev server. -There is a list of demos that can be used to see and test your changes. - -If you need a specific diagram, you can duplicate the `example.html` file in `/demos/dev` and add your own mermaid code to your copy. -That will be served at . -After making code changes, the dev server will rebuild the mermaid library. You will need to reload the browser page yourself to see the changes. (PRs for auto reload are welcome!) - -### Docker - -If you are using docker and docker-compose, you have self-documented `run` bash script, which is a convenient alias for docker-compose commands: - -```bash -./run install # npx pnpm install -./run test # pnpm test -``` - -## Contributing Code - -The basic steps for contributing code are: - -```mermaid-example -graph LR - git[1. Checkout a git branch] --> codeTest[2. Write tests and code] --> doc[3. Update documentation] --> submit[4. Submit a PR] --> review[5. Review and merge] -``` - -```mermaid -graph LR - git[1. Checkout a git branch] --> codeTest[2. Write tests and code] --> doc[3. Update documentation] --> submit[4. Submit a PR] --> review[5. Review and merge] -``` - -1. **Create** and checkout a git branch and work on your code in the branch -2. Write and update **tests** (unit and perhaps even integration (e2e) tests) (If you do TDD/BDD, the order might be different.) -3. **Let users know** that things have changed or been added in the documents! This is often overlooked, but _critical_ -4. **Submit** your code as a _pull request_. -5. Maintainers will **review** your code. If there are no changes necessary, the PR will be merged. Otherwise, make the requested changes and repeat. - -### 1. Checkout a git branch - -Mermaid uses a [Git Flow](https://guides.github.com/introduction/flow/)–inspired approach to branching. - -Development is done in the `develop` branch. - -Once development is done we create a `release/vX.X.X` branch from `develop` for testing. - -Once the release happens we add a tag to the `release` branch and merge it with `master`. The live product and on-line documentation are what is in the `master` branch. - -**All new work should be based on the `develop` branch.** - -**When you are ready to do work, always, ALWAYS:** - -1. Make sure you have the most up-to-date version of the `develop` branch. (fetch or pull to update it) -2. Check out the `develop` branch -3. Create a new branch for your work. Please name the branch following our naming convention below. - -We use the follow naming convention for branches: - -```text - [feature | bug | chore | docs]/[issue number]_[short description using dashes ('-') or underscores ('_') instead of spaces] -``` - -- The first part is the **type** of change: a feature, bug, chore, or documentation change ('docs') -- followed by a _slash_ (which helps to group like types together in many git tools) -- followed by the **issue number** -- followed by an _underscore_ ('\_') -- followed by a short text description (but use dashes ('-') or underscores ('\_') instead of spaces) - -If your work is specific to a single diagram type, it is a good idea to put the diagram type at the start of the description. This will help us keep release notes organized: it will help us keep changes for a diagram type together. - -**Ex: A new feature described in issue 2945 that adds a new arrow type called 'florbs' to state diagrams** - -`feature/2945_state-diagram-new-arrow-florbs` - -**Ex: A bug described in issue 1123 that causes random ugly red text in multiple diagram types** -`bug/1123_fix_random_ugly_red_text` - -### 2. Write Tests - -Tests ensure that each function, module, or part of code does what it says it will do. This is critically -important when other changes are made to ensure that existing code is not broken (no regression). - -Just as important, the tests act as _specifications:_ they specify what the code does (or should do). -Whenever someone is new to a section of code, they should be able to read the tests to get a thorough understanding of what it does and why. - -If you are fixing a bug, you should add tests to ensure that your code has actually fixed the bug, to specify/describe what the code is doing, and to ensure the bug doesn't happen again. -(If there had been a test for the situation, the bug never would have happened in the first place.) -You may need to change existing tests if they were inaccurate. - -If you are adding a feature, you will definitely need to add tests. Depending on the size of your feature, you may need to add integration tests. - -#### Unit Tests - -Unit tests are tests that test a single function or module. They are the easiest to write and the fastest to run. - -Unit tests are mandatory all code except the renderers. (The renderers are tested with integration tests.) - -We use [Vitest](https://vitest.dev) to run unit tests. - -You can use the following command to run the unit tests: - -```sh -pnpm test -``` - -When writing new tests, it's easier to have the tests automatically run as you make changes. You can do this by running the following command: - -```sh -pnpm test:watch -``` - -#### Integration/End-to-End (e2e) tests - -These test the rendering and visual appearance of the diagrams. -This ensures that the rendering of that feature in the e2e will be reviewed in the release process going forward. Less chance that it breaks! - -To start working with the e2e tests: - -1. Run `pnpm dev` to start the dev server -2. Start **Cypress** by running `pnpm cypress:open`. - -The rendering tests are very straightforward to create. There is a function `imgSnapshotTest`, which takes a diagram in text form and the mermaid options, and it renders that diagram in Cypress. - -When running in CI it will take a snapshot of the rendered diagram and compare it with the snapshot from last build and flag it for review if it differs. - -This is what a rendering test looks like: - -```js -it('should render forks and joins', () => { - imgSnapshotTest( - ` - stateDiagram - state fork_state <<fork>> - [*] --> fork_state - fork_state --> State2 - fork_state --> State3 - - state join_state <<join>> - State2 --> join_state - State3 --> join_state - join_state --> State4 - State4 --> [*] - `, - { logLevel: 0 } - ); - cy.get('svg'); -}); -``` - -**_\[TODO - running the tests against what is expected in development. ]_** - -**_\[TODO - how to generate new screenshots]_** -.... - -### 3. Update Documentation - -If the users have no way to know that things have changed, then you haven't really _fixed_ anything for the users; you've just added to making Mermaid feel broken. -Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused. - -The documentation has to be updated to users know that things have changed and added! -If you are adding a new feature, add `(v+)` in the title or description. It will be replaced automatically with the current version number when the release happens. - -eg: `# Feature Name (v+)` - -We know it can sometimes be hard to code _and_ write user documentation. - -Our documentation is managed in `packages/mermaid/src/docs`. Details on how to edit is in the [Contributing Documentation](#contributing-documentation) section. - -Create another issue specifically for the documentation.\ -You will need to help with the PR, but definitely ask for help if you feel stuck. -When it feels hard to write stuff out, explaining it to someone and having that person ask you clarifying questions can often be 80% of the work! - -When in doubt, write up and submit what you can. It can be clarified and refined later. (With documentation, something is better than nothing!) - -### 4. Submit your pull request - -**\[TODO - PR titles should start with (fix | feat | ....)]** - -We make all changes via Pull Requests (PRs). As we have many Pull Requests from developers new to Mermaid, we have put in place a process wherein _knsv, Knut Sveidqvist_ is in charge of the final release process and the active maintainers are in charge of reviewing and merging most PRs. - -- PRs will be reviewed by active maintainers, who will provide feedback and request changes as needed. -- The maintainers will request a review from knsv, if necessary. -- Once the PR is approved, the maintainers will merge the PR into the `develop` branch. -- When a release is ready, the `release/x.x.x` branch will be created, extensively tested and knsv will be in charge of the release process. - -**Reminder: Pull Requests should be submitted to the develop branch.** - -## Contributing Documentation - -**_\[TODO: This section is still a WIP. It still needs MAJOR revision.]_** - -If it is not in the documentation, it's like it never happened. Wouldn't that be sad? With all the effort that was put into the feature? - -The docs are located in the `packages/mermaid/src/docs` folder and are written in Markdown. Just pick the right section and start typing. - -The contents of [mermaid.js.org](https://mermaid.js.org/) are based on the docs from the `master` branch. -Updates committed to the `master` branch are reflected in the [Mermaid Docs](https://mermaid.js.org/) once published. - -### How to Contribute to Documentation - -We are a little less strict here, it is OK to commit directly in the `develop` branch if you are a collaborator. - -The documentation is located in the `packages/mermaid/src/docs` directory and organized according to relevant subfolder. - -The `docs` folder will be automatically generated when committing to `packages/mermaid/src/docs` and **should not** be edited manually. - -```mermaid-example -flowchart LR - classDef default fill:#fff,color:black,stroke:black - - source["files in /packages/mermaid/src/docs\n(changes should be done here)"] -- automatic processing\nto generate the final documentation--> published["files in /docs\ndisplayed on the official documentation site"] - -``` - -```mermaid -flowchart LR - classDef default fill:#fff,color:black,stroke:black - - source["files in /packages/mermaid/src/docs\n(changes should be done here)"] -- automatic processing\nto generate the final documentation--> published["files in /docs\ndisplayed on the official documentation site"] - -``` - -You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box. -Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly. - -```` -```note -Note content -``` - -```tip -Tip content -``` - -```warning -Warning content -``` - -```danger -Danger content -``` - -```` - -> **Note** -> If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. - -We encourage contributions to the documentation at [packages/mermaid/src/docs in the _develop_ branch](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs). - -**_DO NOT CHANGE FILES IN `/docs`_** - -### The official documentation site - -**[The mermaid documentation site](https://mermaid.js.org/) is powered by [Vitepress](https://vitepress.vuejs.org/).** - -To run the documentation site locally: - -1. Run `pnpm --filter mermaid run docs:dev` to start the dev server. (Or `pnpm docs:dev` inside the `packages/mermaid` directory.) -2. Open in your browser. - -Markdown is used to format the text, for more information about Markdown [see the GitHub Markdown help page](https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax). - -To edit Docs on your computer: - -_\[TODO: need to keep this in sync with [check out a git branch in Contributing Code above](#1-checkout-a-git-branch) ]_ - -1. Create a fork of the develop branch to work on. -2. Find the Markdown file (.md) to edit in the `packages/mermaid/src/docs` directory. -3. Make changes or add new documentation. -4. Commit changes to your branch and push it to GitHub (which should create a new branch). -5. Create a Pull Request of your fork. - -To edit Docs on GitHub: - -1. Login to [GitHub.com](https://www.github.com). -2. Navigate to [packages/mermaid/src/docs](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs) in the mermaid-js repository. -3. To edit a file, click the pencil icon at the top-right of the file contents panel. -4. Describe what you changed in the **Propose file change** section, located at the bottom of the page. -5. Submit your changes by clicking the button **Propose file change** at the bottom (by automatic creation of a fork and a new branch). -6. Visit the Actions tab in Github, `https://github.com//mermaid/actions` and enable the actions for your fork. This will ensure that the documentation is built and updated in your fork. -7. Create a Pull Request of your newly forked branch by clicking the green **Create Pull Request** button. - -### Documentation organization: Sidebar navigation - -If you want to propose changes to how the documentation is _organized_, such as adding a new section or re-arranging or renaming a section, you must update the **sidebar navigation.** - -The sidebar navigation is defined in [the vitepress configuration file config.ts](../.vitepress/config.ts). - -## Questions or Suggestions? - -#### First search to see if someone has already asked (and hopefully been answered) or suggested the same thing. - -- Search in Discussions -- Search in open Issues -- Search in closed Issues - -If you find an open issue or discussion thread that is similar to your question but isn't answered, you can let us know that you are also interested in it. -Use the GitHub reactions to add a thumbs-up to the issue or discussion thread. - -This helps the team know the relative interest in something and helps them set priorities and assignments. - -Feel free to add to the discussion on the issue or topic. - -If you can't find anything that already addresses your question or suggestion, _open a new issue:_ - -Log in to [GitHub.com](https://www.github.com), open or append to an issue [using the GitHub issue tracker of the mermaid-js repository](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Documentation%22). - -### How to Contribute a Suggestion +All tests should run successfully without any errors or failures. (You might see _lint_ or _formatting_ warnings; those are ok during this step.) ## Last Words diff --git a/docs/community/docker-development.md b/docs/community/docker-development.md new file mode 100644 index 000000000..4b206408c --- /dev/null +++ b/docs/community/docker-development.md @@ -0,0 +1,109 @@ +> **Warning** +> +> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. +> +> ## Please edit the corresponding file in [/packages/mermaid/src/docs/community/docker-development.md](../../packages/mermaid/src/docs/community/docker-development.md). + +# Contributing to Mermaid via Docker + +> The following documentation describes how to work with Mermaid in a Docker environment. +> There's also a [host installation guide](../community/development.md) +> if you prefer to work without a Docker environment. + +So you want to help? That's great! + +![Image of happy people jumping with excitement](https://media.giphy.com/media/BlVnrxJgTGsUw/giphy.gif) + +Here are a few things to get you started on the right path. + +## Get the Source Code + +In GitHub, you first **fork** a repository when you are going to make changes and submit pull requests. + +Then you **clone** a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with. + +[Fork mermaid](https://github.com/mermaid-js/mermaid/fork) to start contributing to the main project and its documentaion, or [search for other repositories](https://github.com/orgs/mermaid-js/repositories). + +[Here is a GitHub document that gives an overview of the process.](https://docs.github.com/en/get-started/quickstart/fork-a-repo) + +## Technical Requirements + +> The following documentation describes how to work with Mermaid in a Docker environment. +> There's also a [host installation guide](../community/development.md) +> if you prefer to work without a Docker environment. + +[Install Docker](https://docs.docker.com/engine/install/). And that is pretty much all you need. + +Optionally, to run GUI (Cypress) within Docker you will also need X11 server installed. +Maybe you already have it installed, so check it first: + +```bash +echo $DISPLAY +``` + +If variable `$DISPLAY` is not empty, then it must be working. Otherwise install it. + +## Setup and Launch + +### Switch to project + +Once you have cloned the repository onto your development machine, change into the `mermaid` project folder (the top level directory of the mermaid project repository) + +```bash +cd mermaid +``` + +### Make `./run` executable + +For development using Docker there is a self-documented `run` bash script, which provides convenient aliases for `docker compose` commands. + +Ensure `./run` script is executable: + +```bash +chmod +x run +``` + +> **💡 Tip** +> To get detailed help simply type `./run` or `./run help`. +> +> It also has short _Development quick start guide_ embedded. + +### Install packages + +```bash +./run pnpm install # Install packages +``` + +### Launch + +```bash +./run dev +``` + +Now you are ready to make your changes! Edit whichever files in `src` as required. + +Open in your browser, after starting the dev server. +There is a list of demos that can be used to see and test your changes. + +If you need a specific diagram, you can duplicate the `example.html` file in `/demos/dev` and add your own mermaid code to your copy. + +That will be served at . +After making code changes, the dev server will rebuild the mermaid library. You will need to reload the browser page yourself to see the changes. (PRs for auto reload are welcome!) + +## Verify Everything is Working + +```bash +./run pnpm test +``` + +The `test` script and others are in the top-level `package.json` file. + +All tests should run successfully without any errors or failures. (You might see _lint_ or _formatting_ warnings; those are ok during this step.) + +## Last Words + +Don't get daunted if it is hard in the beginning. We have a great community with only encouraging words. So, if you get stuck, ask for help and hints in the Slack forum. If you want to show off something good, show it off there. + +[Join our Slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) + +![Image of superhero wishing you good luck](https://media.giphy.com/media/l49JHz7kJvl6MCj3G/giphy.gif) diff --git a/docs/community/documentation.md b/docs/community/documentation.md new file mode 100644 index 000000000..b4f19597a --- /dev/null +++ b/docs/community/documentation.md @@ -0,0 +1,106 @@ +> **Warning** +> +> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. +> +> ## Please edit the corresponding file in [/packages/mermaid/src/docs/community/documentation.md](../../packages/mermaid/src/docs/community/documentation.md). + +# Contributing Documentation + +**_\[TODO: This section is still a WIP. It still needs MAJOR revision.]_** + +If it is not in the documentation, it's like it never happened. Wouldn't that be sad? With all the effort that was put into the feature? + +The docs are located in the `packages/mermaid/src/docs` folder and are written in Markdown. Just pick the right section and start typing. + +The contents of [mermaid.js.org](https://mermaid.js.org/) are based on the docs from the `master` branch. +Updates committed to the `master` branch are reflected in the [Mermaid Docs](https://mermaid.js.org/) once published. + +## How to Contribute to Documentation + +We are a little less strict here, it is OK to commit directly in the `develop` branch if you are a collaborator. + +The documentation is located in the `packages/mermaid/src/docs` directory and organized according to relevant subfolder. + +The `docs` folder will be automatically generated when committing to `packages/mermaid/src/docs` and **should not** be edited manually. + +```mermaid-example +flowchart LR + classDef default fill:#fff,color:black,stroke:black + + source["files in /packages/mermaid/src/docs\n(changes should be done here)"] -- automatic processing\nto generate the final documentation--> published["files in /docs\ndisplayed on the official documentation site"] + +``` + +```mermaid +flowchart LR + classDef default fill:#fff,color:black,stroke:black + + source["files in /packages/mermaid/src/docs\n(changes should be done here)"] -- automatic processing\nto generate the final documentation--> published["files in /docs\ndisplayed on the official documentation site"] + +``` + +You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box. +Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly. + +```` +```note +Note content +``` + +```tip +Tip content +``` + +```warning +Warning content +``` + +```danger +Danger content +``` + +```` + +> **Note** +> If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. + +We encourage contributions to the documentation at [packages/mermaid/src/docs in the _develop_ branch](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs). + +**_DO NOT CHANGE FILES IN `/docs`_** + +## The official documentation site + +**[The mermaid documentation site](https://mermaid.js.org/) is powered by [Vitepress](https://vitepress.vuejs.org/).** + +To run the documentation site locally: + +1. Run `pnpm --filter mermaid run docs:dev` to start the dev server. (Or `pnpm docs:dev` inside the `packages/mermaid` directory.) +2. Open in your browser. + +Markdown is used to format the text, for more information about Markdown [see the GitHub Markdown help page](https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax). + +To edit Docs on your computer: + +_\[TODO: need to keep this in sync with [check out a git branch in Contributing Code above](#1-checkout-a-git-branch) ]_ + +1. Create a fork of the develop branch to work on. +2. Find the Markdown file (.md) to edit in the `packages/mermaid/src/docs` directory. +3. Make changes or add new documentation. +4. Commit changes to your branch and push it to GitHub (which should create a new branch). +5. Create a Pull Request of your fork. + +To edit Docs on GitHub: + +1. Login to [GitHub.com](https://www.github.com). +2. Navigate to [packages/mermaid/src/docs](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs) in the mermaid-js repository. +3. To edit a file, click the pencil icon at the top-right of the file contents panel. +4. Describe what you changed in the **Propose file change** section, located at the bottom of the page. +5. Submit your changes by clicking the button **Propose file change** at the bottom (by automatic creation of a fork and a new branch). +6. Visit the Actions tab in Github, `https://github.com//mermaid/actions` and enable the actions for your fork. This will ensure that the documentation is built and updated in your fork. +7. Create a Pull Request of your newly forked branch by clicking the green **Create Pull Request** button. + +## Documentation organization: Sidebar navigation + +If you want to propose changes to how the documentation is _organized_, such as adding a new section or re-arranging or renaming a section, you must update the **sidebar navigation.** + +The sidebar navigation is defined in [the vitepress configuration file config.ts](../.vitepress/config.ts). diff --git a/docs/community/n00b-overview.md b/docs/community/n00b-overview.md deleted file mode 100644 index afb110e9e..000000000 --- a/docs/community/n00b-overview.md +++ /dev/null @@ -1,74 +0,0 @@ -> **Warning** -> -> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. -> -> ## Please edit the corresponding file in [/packages/mermaid/src/docs/community/n00b-overview.md](../../packages/mermaid/src/docs/community/n00b-overview.md). - -# Overview for Beginners - -**Explaining with a Diagram** - -A picture is worth a thousand words, a good diagram is undoubtedly worth more. They make understanding easier. - -## Creating and Maintaining Diagrams - -Anyone who has used Visio, or (God Forbid) Excel to make a Gantt Chart, knows how hard it is to create, edit and maintain good visualizations. - -Diagrams/Charts are significant but also become obsolete/inaccurate very fast. This catch-22 hobbles the productivity of teams. - -# Doc Rot in Diagrams - -Doc-Rot kills diagrams as quickly as it does text, but it takes hours in a desktop application to produce a diagram. - -Mermaid seeks to change using markdown-inspired syntax. The process is a quicker, less complicated, and more convenient way of going from concept to visualization. - -It is a relatively straightforward solution to a significant hurdle with the software teams. - -# Definition of Terms/ Dictionary - -**Mermaid text definitions can be saved for later reuse and editing.** - -> These are the Mermaid diagram definitions inside `
` tags, with the `class=mermaid`. - -```html -
-    graph TD
-    A[Client] --> B[Load Balancer]
-    B --> C[Server01]
-    B --> D[Server02]
-
-``` - -**render** - -> This is the core function of the Mermaid API. It reads all the `Mermaid Definitions` inside `div` tags and returns an SVG file, based on the definition. - -**Nodes** - -> These are the boxes that contain text or otherwise discrete pieces of each diagram, separated generally by arrows, except for Gantt Charts and User Journey Diagrams. They will be referred often in the instructions. Read for Diagram Specific [Syntax](../intro/n00b-syntaxReference.md) - -## Advantages of using Mermaid - -- Ease to generate, modify and render diagrams when you make them. -- The number of integrations and plugins it has. -- You can add it to your or companies website. -- Diagrams can be created through comments like this in a script: - -## The catch-22 of Diagrams and Charts: - -**Diagramming and charting is a large waste of developer's time, but not having diagrams ruins productivity.** - -Mermaid solves this by reducing the time and effort required to create diagrams and charts. - -Because, the text base for the diagrams allows it to be updated easily. Also, it can be made part of production scripts (and other pieces of code). So less time is spent on documenting, as a separate task. - -## Catching up with Development - -Being based on markdown, Mermaid can be used, not only by accomplished front-end developers, but by most computer savvy people to render diagrams, at much faster speeds. -In fact one can pick up the syntax for it quite easily from the examples given and there are many tutorials available in the internet. - -## Mermaid is for everyone. - -Video [Tutorials](https://mermaid.js.org/config/Tutorials.html) are also available for the mermaid [live editor](https://mermaid.live/). - -Alternatively you can use Mermaid [Plug-Ins](https://mermaid-js.github.io/mermaid/#/./integrations), with tools you already use, like Google Docs. diff --git a/docs/community/questionsAndSuggestions.md b/docs/community/questionsAndSuggestions.md new file mode 100644 index 000000000..28b107d1f --- /dev/null +++ b/docs/community/questionsAndSuggestions.md @@ -0,0 +1,28 @@ +> **Warning** +> +> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. +> +> ## Please edit the corresponding file in [/packages/mermaid/src/docs/community/questionsAndSuggestions.md](../../packages/mermaid/src/docs/community/questionsAndSuggestions.md). + +# Questions or Suggestions? + +**_\[TODO: This section is still a WIP. It still needs MAJOR revision.]_** + +## First search to see if someone has already asked (and hopefully been answered) or suggested the same thing. + +- Search in Discussions +- Search in open Issues +- Search in closed Issues + +If you find an open issue or discussion thread that is similar to your question but isn't answered, you can let us know that you are also interested in it. +Use the GitHub reactions to add a thumbs-up to the issue or discussion thread. + +This helps the team know the relative interest in something and helps them set priorities and assignments. + +Feel free to add to the discussion on the issue or topic. + +If you can't find anything that already addresses your question or suggestion, _open a new issue:_ + +Log in to [GitHub.com](https://www.github.com), open or append to an issue [using the GitHub issue tracker of the mermaid-js repository](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Documentation%22). + +## How to Contribute a Suggestion diff --git a/docs/intro/index.md b/docs/intro/index.md index 6b811d86e..89af6ecd1 100644 --- a/docs/intro/index.md +++ b/docs/intro/index.md @@ -322,6 +322,7 @@ To Deploy Mermaid: - [Mermaid CLI](https://github.com/mermaid-js/mermaid-cli) - [Mermaid Webpack Demo](https://github.com/mermaidjs/mermaid-webpack-demo) - [Mermaid Parcel Demo](https://github.com/mermaidjs/mermaid-parcel-demo) +- [HTTP Server](https://github.com/TomWright/mermaid-server) ## Request for Assistance @@ -338,7 +339,17 @@ Together we could continue the work with things like: Don't hesitate to contact me if you want to get involved! -## For contributors +## Contributors + +
+ +[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) [![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) [![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) + +
+ +Mermaid is a growing community and is always accepting new contributors. There's a lot of different ways to help out and we're always looking for extra hands! Look at [this issue](https://github.com/mermaid-js/mermaid/issues/866) if you want to know where to start helping out. + +Detailed information about how to contribute can be found in the [contribution guideline](/community/development). ### Requirements @@ -346,7 +357,7 @@ Don't hesitate to contact me if you want to get involved! - [Node.js](https://nodejs.org/en/). `volta install node` - [pnpm](https://pnpm.io/) package manager. `volta install pnpm` -## Development Installation +### Development Installation ```bash git clone git@github.com:mermaid-js/mermaid.git @@ -383,25 +394,7 @@ Update version number in `package.json`. npm publish ``` -The above command generates files into the `dist` folder and publishes them to \. - -## Related projects - -- [Command Line Interface](https://github.com/mermaid-js/mermaid-cli) -- [Live Editor](https://github.com/mermaid-js/mermaid-live-editor) -- [HTTP Server](https://github.com/TomWright/mermaid-server) - -## Contributors - -
- -[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) [![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) [![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) - -
- -Mermaid is a growing community and is always accepting new contributors. There's a lot of different ways to help out and we're always looking for extra hands! Look at [this issue](https://github.com/mermaid-js/mermaid/issues/866) if you want to know where to start helping out. - -Detailed information about how to contribute can be found in the [contribution guide](https://github.com/mermaid-js/mermaid/blob/develop/CONTRIBUTING.md) +The above command generates files into the `dist` folder and publishes them to [npmjs.org](npmjs.org). ## Security and safe diagrams diff --git a/docs/intro/n00b-syntaxReference.md b/docs/intro/n00b-syntaxReference.md index c51b1680e..e8c5dab68 100644 --- a/docs/intro/n00b-syntaxReference.md +++ b/docs/intro/n00b-syntaxReference.md @@ -56,11 +56,11 @@ One should **beware the use of some words or symbols** that can break diagrams. | 'end' | The word "End" can cause Flowcharts and Sequence diagrams to break | Wrap them in quotation marks to prevent breakage. | | [Nodes inside Nodes](../syntax/flowchart.md?id=special-characters-that-break-syntax) | Mermaid gets confused with nested shapes | wrap them in quotation marks to prevent breaking | -### Mermaid Live Editor +## Mermaid Live Editor Now, that you've seen what you should not add to your diagrams, you can play around with them in the [Mermaid Live Editor](https://mermaid.live). -# Configuration +## Configuration Configuration is the third part of Mermaid, after deployment and syntax. It deals with the different ways that Mermaid can be customized across different deployments. diff --git a/packages/mermaid/src/docs/.vitepress/config.ts b/packages/mermaid/src/docs/.vitepress/config.ts index 06485ab7d..f86da0490 100644 --- a/packages/mermaid/src/docs/.vitepress/config.ts +++ b/packages/mermaid/src/docs/.vitepress/config.ts @@ -72,6 +72,11 @@ function nav() { activeMatch: '/config/', }, { text: 'Integrations', link: '/ecosystem/integrations', activeMatch: '/ecosystem/' }, + { + text: 'Contributing', + link: '/community/development.html', + activeMatch: '/community/', + }, { text: 'Latest News', link: '/news/announcements', @@ -104,11 +109,8 @@ function sidebarAll() { collapsed: false, items: [ { text: 'About Mermaid', link: '/intro/' }, - { text: 'Deployment', link: '/intro/n00b-gettingStarted' }, - { - text: 'Syntax and Configuration', - link: '/intro/n00b-syntaxReference', - }, + { text: 'Getting Started', link: '/intro/n00b-gettingStarted' }, + { text: 'Syntax and Configuration', link: '/intro/n00b-syntaxReference' }, ], }, ...sidebarSyntax(), @@ -191,8 +193,10 @@ function sidebarCommunity() { text: '🙌 Contributions and Community', collapsed: false, items: [ - { text: 'Overview for Beginners', link: '/community/n00b-overview' }, - ...sidebarCommunityDevelopContribute(), + { text: 'Contributing to Mermaid', link: '/community/development' }, + { text: 'Contributing Code', link: '/community/code' }, + { text: 'Contributing Documentation', link: '/community/documentation' }, + { text: 'Questions and Suggestions', link: '/community/questionsAndSuggestions' }, { text: 'Adding Diagrams', link: '/community/newDiagram' }, { text: 'Security', link: '/community/security' }, ], @@ -200,40 +204,6 @@ function sidebarCommunity() { ]; } -// Development and Contributing -function sidebarCommunityDevelopContribute() { - const page_path = '/community/development'; - return [ - { - text: 'Contributing to Mermaid', - link: page_path + '#contributing-to-mermaid', - collapsed: false, - items: [ - { - text: 'Technical Requirements and Setup', - link: pathToId(page_path, 'technical-requirements-and-setup'), - }, - { - text: 'Contributing Code', - link: pathToId(page_path, 'contributing-code'), - }, - { - text: 'Contributing Documentation', - link: pathToId(page_path, 'contributing-documentation'), - }, - { - text: 'Questions or Suggestions?', - link: pathToId(page_path, 'questions-or-suggestions'), - }, - { - text: 'Last Words', - link: pathToId(page_path, 'last-words'), - }, - ], - }, - ]; -} - function sidebarNews() { return [ { diff --git a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts index da32e5f8f..da4326be7 100644 --- a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts +++ b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts @@ -50,6 +50,7 @@ const idRedirectMap: Record = { 'n00b-advanced': 'config/n00b-advanced', 'n00b-gettingstarted': 'intro/n00b-gettingStarted', 'n00b-overview': 'community/n00b-overview', + 'community/n00b-overview': 'intro/n00b-gettingStarted', 'n00b-syntaxreference': 'intro/n00b-syntaxReference', newdiagram: 'community/newDiagram', pie: 'syntax/pie', diff --git a/packages/mermaid/src/docs/community/code.md b/packages/mermaid/src/docs/community/code.md new file mode 100644 index 000000000..cfbba8b7e --- /dev/null +++ b/packages/mermaid/src/docs/community/code.md @@ -0,0 +1,165 @@ +# Contributing Code + +The basic steps for contributing code are: + +```mermaid +graph LR + git[1. Checkout a git branch] --> codeTest[2. Write tests and code] --> doc[3. Update documentation] --> submit[4. Submit a PR] --> review[5. Review and merge] +``` + +1. **Create** and checkout a git branch and work on your code in the branch +2. Write and update **tests** (unit and perhaps even integration (e2e) tests) (If you do TDD/BDD, the order might be different.) +3. **Let users know** that things have changed or been added in the documents! This is often overlooked, but _critical_ +4. **Submit** your code as a _pull request_. +5. Maintainers will **review** your code. If there are no changes necessary, the PR will be merged. Otherwise, make the requested changes and repeat. + +## 1. Checkout a git branch + +Mermaid uses a [Git Flow](https://guides.github.com/introduction/flow/)–inspired approach to branching. + +Development is done in the `develop` branch. + +Once development is done we create a `release/vX.X.X` branch from `develop` for testing. + +Once the release happens we add a tag to the `release` branch and merge it with `master`. The live product and on-line documentation are what is in the `master` branch. + +**All new work should be based on the `develop` branch.** + +**When you are ready to do work, always, ALWAYS:** + +1. Make sure you have the most up-to-date version of the `develop` branch. (fetch or pull to update it) +2. Check out the `develop` branch +3. Create a new branch for your work. Please name the branch following our naming convention below. + +We use the follow naming convention for branches: + +```txt + [feature | bug | chore | docs]/[issue number]_[short description using dashes ('-') or underscores ('_') instead of spaces] +``` + +You can always check current [configuration of labelling and branch prefixes](https://github.com/mermaid-js/mermaid/blob/develop/.github/pr-labeler.yml) + +- The first part is the **type** of change: a feature, bug, chore, or documentation change ('docs') +- followed by a _slash_ (which helps to group like types together in many git tools) +- followed by the **issue number** +- followed by an _underscore_ ('\_') +- followed by a short text description (but use dashes ('-') or underscores ('\_') instead of spaces) + +If your work is specific to a single diagram type, it is a good idea to put the diagram type at the start of the description. This will help us keep release notes organized: it will help us keep changes for a diagram type together. + +**Ex: A new feature described in issue 2945 that adds a new arrow type called 'florbs' to state diagrams** + +`feature/2945_state-diagram-new-arrow-florbs` + +**Ex: A bug described in issue 1123 that causes random ugly red text in multiple diagram types** +`bug/1123_fix_random_ugly_red_text` + +## 2. Write Tests + +Tests ensure that each function, module, or part of code does what it says it will do. This is critically +important when other changes are made to ensure that existing code is not broken (no regression). + +Just as important, the tests act as _specifications:_ they specify what the code does (or should do). +Whenever someone is new to a section of code, they should be able to read the tests to get a thorough understanding of what it does and why. + +If you are fixing a bug, you should add tests to ensure that your code has actually fixed the bug, to specify/describe what the code is doing, and to ensure the bug doesn't happen again. +(If there had been a test for the situation, the bug never would have happened in the first place.) +You may need to change existing tests if they were inaccurate. + +If you are adding a feature, you will definitely need to add tests. Depending on the size of your feature, you may need to add integration tests. + +### Unit Tests + +Unit tests are tests that test a single function or module. They are the easiest to write and the fastest to run. + +Unit tests are mandatory all code except the renderers. (The renderers are tested with integration tests.) + +We use [Vitest](https://vitest.dev) to run unit tests. + +You can use the following command to run the unit tests: + +```sh +pnpm test +``` + +When writing new tests, it's easier to have the tests automatically run as you make changes. You can do this by running the following command: + +```sh +pnpm test:watch +``` + +### Integration/End-to-End (e2e) tests + +These test the rendering and visual appearance of the diagrams. +This ensures that the rendering of that feature in the e2e will be reviewed in the release process going forward. Less chance that it breaks! + +To start working with the e2e tests: + +1. Run `pnpm dev` to start the dev server +2. Start **Cypress** by running `pnpm cypress:open`. + +The rendering tests are very straightforward to create. There is a function `imgSnapshotTest`, which takes a diagram in text form and the mermaid options, and it renders that diagram in Cypress. + +When running in CI it will take a snapshot of the rendered diagram and compare it with the snapshot from last build and flag it for review if it differs. + +This is what a rendering test looks like: + +```js +it('should render forks and joins', () => { + imgSnapshotTest( + ` + stateDiagram + state fork_state <<fork>> + [*] --> fork_state + fork_state --> State2 + fork_state --> State3 + + state join_state <<join>> + State2 --> join_state + State3 --> join_state + join_state --> State4 + State4 --> [*] + `, + { logLevel: 0 } + ); + cy.get('svg'); +}); +``` + +**_[TODO - running the tests against what is expected in development. ]_** + +**_[TODO - how to generate new screenshots]_** +.... + +## 3. Update Documentation + +If the users have no way to know that things have changed, then you haven't really _fixed_ anything for the users; you've just added to making Mermaid feel broken. +Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused. + +The documentation has to be updated to users know that things have changed and added! +If you are adding a new feature, add `(v+)` in the title or description. It will be replaced automatically with the current version number when the release happens. + +eg: `# Feature Name (v+)` + +We know it can sometimes be hard to code _and_ write user documentation. + +Our documentation is managed in `packages/mermaid/src/docs`. Details on how to edit is in the [Contributing Documentation](#contributing-documentation) section. + +Create another issue specifically for the documentation. +You will need to help with the PR, but definitely ask for help if you feel stuck. +When it feels hard to write stuff out, explaining it to someone and having that person ask you clarifying questions can often be 80% of the work! + +When in doubt, write up and submit what you can. It can be clarified and refined later. (With documentation, something is better than nothing!) + +## 4. Submit your pull request + +**[TODO - PR titles should start with (fix | feat | ....)]** + +We make all changes via Pull Requests (PRs). As we have many Pull Requests from developers new to Mermaid, we have put in place a process wherein _knsv, Knut Sveidqvist_ is in charge of the final release process and the active maintainers are in charge of reviewing and merging most PRs. + +- PRs will be reviewed by active maintainers, who will provide feedback and request changes as needed. +- The maintainers will request a review from knsv, if necessary. +- Once the PR is approved, the maintainers will merge the PR into the `develop` branch. +- When a release is ready, the `release/x.x.x` branch will be created, extensively tested and knsv will be in charge of the release process. + +**Reminder: Pull Requests should be submitted to the develop branch.** diff --git a/packages/mermaid/src/docs/community/development.md b/packages/mermaid/src/docs/community/development.md index 35a01e589..e3c0826fd 100644 --- a/packages/mermaid/src/docs/community/development.md +++ b/packages/mermaid/src/docs/community/development.md @@ -1,14 +1,8 @@ # Contributing to Mermaid -## Contents - -- [Technical Requirements and Setup](#technical-requirements-and-setup) -- [Contributing Code](#contributing-code) -- [Contributing Documentation](#contributing-documentation) -- [Questions or Suggestions?](#questions-or-suggestions) -- [Last Words](#last-words) - ---- +> The following documentation describes how to work with Mermaid in your host environment. +> There's also a [Docker installation guide](../community/docker-development.md) +> if you prefer to work in a Docker environment. So you want to help? That's great! @@ -16,47 +10,68 @@ So you want to help? That's great! Here are a few things to get you started on the right path. -## Technical Requirements and Setup +## Get the Source Code -### Technical Requirements +In GitHub, you first **fork** a repository when you are going to make changes and submit pull requests. -These are the tools we use for working with the code and documentation. +Then you **clone** a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with. + +[Fork mermaid](https://github.com/mermaid-js/mermaid/fork) to start contributing to the main project and its documentaion, or [search for other repositories](https://github.com/orgs/mermaid-js/repositories). + +[Here is a GitHub document that gives an overview of the process.](https://docs.github.com/en/get-started/quickstart/fork-a-repo) + +## Technical Requirements + +> The following documentation describes how to work with Mermaid in your host environment. +> There's also a [Docker installation guide](../community/docker-development.md) +> if you prefer to work in a Docker environment. + +These are the tools we use for working with the code and documentation: - [volta](https://volta.sh/) to manage node versions. - [Node.js](https://nodejs.org/en/). `volta install node` - [pnpm](https://pnpm.io/) package manager. `volta install pnpm` -- [npx](https://docs.npmjs.com/cli/v8/commands/npx) the packaged executor in npm. This is needed [to install pnpm.](#2-install-pnpm) +- [npx](https://docs.npmjs.com/cli/v8/commands/npx) the packaged executor in npm. This is needed [to install pnpm.](#install-packages) -Follow [the setup steps below](#setup) to install them and verify they are working +Follow the setup steps below to install them and start the development. -### Setup +## Setup and Launch -Follow these steps to set up the environment you need to work on code and/or documentation. +### Switch to project -#### 1. Fork and clone the repository - -In GitHub, you first _fork_ a repository when you are going to make changes and submit pull requests. - -Then you _clone_ a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with. - -[Here is a GitHub document that gives an overview of the process.](https://docs.github.com/en/get-started/quickstart/fork-a-repo) - -#### 2. Install pnpm - -Once you have cloned the repository onto your development machine, change into the `mermaid` project folder so that you can install `pnpm`. You will need `npx` to install pnpm because volta doesn't support it yet. - -Ex: +Once you have cloned the repository onto your development machine, change into the `mermaid` project folder (the top level directory of the mermaid project repository) ```bash -# Change into the mermaid directory (the top level director of the mermaid project repository) cd mermaid -# npx is required for first install because volta does not support pnpm yet -npx pnpm install ``` -#### 3. Verify Everything Is Working +### Install packages -Once you have installed pnpm, you can run the `test` script to verify that pnpm is working _and_ that the repository has been cloned correctly: +Run `npx pnpm install`. You will need `npx` for this because volta doesn't support it yet. + +```bash +npx pnpm install # npx is required for first install +``` + +### Launch + +```bash +npx pnpm run dev +``` + +Now you are ready to make your changes! Edit whichever files in `src` as required. + +Open in your browser, after starting the dev server. +There is a list of demos that can be used to see and test your changes. + +If you need a specific diagram, you can duplicate the `example.html` file in `/demos/dev` and add your own mermaid code to your copy. + +That will be served at . +After making code changes, the dev server will rebuild the mermaid library. You will need to reload the browser page yourself to see the changes. (PRs for auto reload are welcome!) + +## Verify Everything is Working + +You can run the `test` script to verify that pnpm is working _and_ that the repository has been cloned correctly: ```bash pnpm test @@ -64,309 +79,7 @@ pnpm test The `test` script and others are in the top-level `package.json` file. -All tests should run successfully without any errors or failures. (You might see _lint_ or _formatting_ "warnings"; those are ok during this step.) - -#### 4. Make your changes - -Now you are ready to make your changes! -Edit whichever files in `src` as required. - -#### 5. See your changes - -Open in your browser, after starting the dev server. -There is a list of demos that can be used to see and test your changes. - -If you need a specific diagram, you can duplicate the `example.html` file in `/demos/dev` and add your own mermaid code to your copy. -That will be served at . -After making code changes, the dev server will rebuild the mermaid library. You will need to reload the browser page yourself to see the changes. (PRs for auto reload are welcome!) - -### Docker - -If you are using docker and docker-compose, you have self-documented `run` bash script, which is a convenient alias for docker-compose commands: - -```bash -./run install # npx pnpm install -./run test # pnpm test -``` - -## Contributing Code - -The basic steps for contributing code are: - -```mermaid -graph LR - git[1. Checkout a git branch] --> codeTest[2. Write tests and code] --> doc[3. Update documentation] --> submit[4. Submit a PR] --> review[5. Review and merge] -``` - -1. **Create** and checkout a git branch and work on your code in the branch -2. Write and update **tests** (unit and perhaps even integration (e2e) tests) (If you do TDD/BDD, the order might be different.) -3. **Let users know** that things have changed or been added in the documents! This is often overlooked, but _critical_ -4. **Submit** your code as a _pull request_. -5. Maintainers will **review** your code. If there are no changes necessary, the PR will be merged. Otherwise, make the requested changes and repeat. - -### 1. Checkout a git branch - -Mermaid uses a [Git Flow](https://guides.github.com/introduction/flow/)–inspired approach to branching. - -Development is done in the `develop` branch. - -Once development is done we create a `release/vX.X.X` branch from `develop` for testing. - -Once the release happens we add a tag to the `release` branch and merge it with `master`. The live product and on-line documentation are what is in the `master` branch. - -**All new work should be based on the `develop` branch.** - -**When you are ready to do work, always, ALWAYS:** - -1. Make sure you have the most up-to-date version of the `develop` branch. (fetch or pull to update it) -2. Check out the `develop` branch -3. Create a new branch for your work. Please name the branch following our naming convention below. - -We use the follow naming convention for branches: - -```text - [feature | bug | chore | docs]/[issue number]_[short description using dashes ('-') or underscores ('_') instead of spaces] -``` - -- The first part is the **type** of change: a feature, bug, chore, or documentation change ('docs') -- followed by a _slash_ (which helps to group like types together in many git tools) -- followed by the **issue number** -- followed by an _underscore_ ('\_') -- followed by a short text description (but use dashes ('-') or underscores ('\_') instead of spaces) - -If your work is specific to a single diagram type, it is a good idea to put the diagram type at the start of the description. This will help us keep release notes organized: it will help us keep changes for a diagram type together. - -**Ex: A new feature described in issue 2945 that adds a new arrow type called 'florbs' to state diagrams** - -`feature/2945_state-diagram-new-arrow-florbs` - -**Ex: A bug described in issue 1123 that causes random ugly red text in multiple diagram types** -`bug/1123_fix_random_ugly_red_text` - -### 2. Write Tests - -Tests ensure that each function, module, or part of code does what it says it will do. This is critically -important when other changes are made to ensure that existing code is not broken (no regression). - -Just as important, the tests act as _specifications:_ they specify what the code does (or should do). -Whenever someone is new to a section of code, they should be able to read the tests to get a thorough understanding of what it does and why. - -If you are fixing a bug, you should add tests to ensure that your code has actually fixed the bug, to specify/describe what the code is doing, and to ensure the bug doesn't happen again. -(If there had been a test for the situation, the bug never would have happened in the first place.) -You may need to change existing tests if they were inaccurate. - -If you are adding a feature, you will definitely need to add tests. Depending on the size of your feature, you may need to add integration tests. - -#### Unit Tests - -Unit tests are tests that test a single function or module. They are the easiest to write and the fastest to run. - -Unit tests are mandatory all code except the renderers. (The renderers are tested with integration tests.) - -We use [Vitest](https://vitest.dev) to run unit tests. - -You can use the following command to run the unit tests: - -```sh -pnpm test -``` - -When writing new tests, it's easier to have the tests automatically run as you make changes. You can do this by running the following command: - -```sh -pnpm test:watch -``` - -#### Integration/End-to-End (e2e) tests - -These test the rendering and visual appearance of the diagrams. -This ensures that the rendering of that feature in the e2e will be reviewed in the release process going forward. Less chance that it breaks! - -To start working with the e2e tests: - -1. Run `pnpm dev` to start the dev server -2. Start **Cypress** by running `pnpm cypress:open`. - -The rendering tests are very straightforward to create. There is a function `imgSnapshotTest`, which takes a diagram in text form and the mermaid options, and it renders that diagram in Cypress. - -When running in CI it will take a snapshot of the rendered diagram and compare it with the snapshot from last build and flag it for review if it differs. - -This is what a rendering test looks like: - -```js -it('should render forks and joins', () => { - imgSnapshotTest( - ` - stateDiagram - state fork_state <<fork>> - [*] --> fork_state - fork_state --> State2 - fork_state --> State3 - - state join_state <<join>> - State2 --> join_state - State3 --> join_state - join_state --> State4 - State4 --> [*] - `, - { logLevel: 0 } - ); - cy.get('svg'); -}); -``` - -**_[TODO - running the tests against what is expected in development. ]_** - -**_[TODO - how to generate new screenshots]_** -.... - -### 3. Update Documentation - -If the users have no way to know that things have changed, then you haven't really _fixed_ anything for the users; you've just added to making Mermaid feel broken. -Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused. - -The documentation has to be updated to users know that things have changed and added! -If you are adding a new feature, add `(v+)` in the title or description. It will be replaced automatically with the current version number when the release happens. - -eg: `# Feature Name (v+)` - -We know it can sometimes be hard to code _and_ write user documentation. - -Our documentation is managed in `packages/mermaid/src/docs`. Details on how to edit is in the [Contributing Documentation](#contributing-documentation) section. - -Create another issue specifically for the documentation. -You will need to help with the PR, but definitely ask for help if you feel stuck. -When it feels hard to write stuff out, explaining it to someone and having that person ask you clarifying questions can often be 80% of the work! - -When in doubt, write up and submit what you can. It can be clarified and refined later. (With documentation, something is better than nothing!) - -### 4. Submit your pull request - -**[TODO - PR titles should start with (fix | feat | ....)]** - -We make all changes via Pull Requests (PRs). As we have many Pull Requests from developers new to Mermaid, we have put in place a process wherein _knsv, Knut Sveidqvist_ is in charge of the final release process and the active maintainers are in charge of reviewing and merging most PRs. - -- PRs will be reviewed by active maintainers, who will provide feedback and request changes as needed. -- The maintainers will request a review from knsv, if necessary. -- Once the PR is approved, the maintainers will merge the PR into the `develop` branch. -- When a release is ready, the `release/x.x.x` branch will be created, extensively tested and knsv will be in charge of the release process. - -**Reminder: Pull Requests should be submitted to the develop branch.** - -## Contributing Documentation - -**_[TODO: This section is still a WIP. It still needs MAJOR revision.]_** - -If it is not in the documentation, it's like it never happened. Wouldn't that be sad? With all the effort that was put into the feature? - -The docs are located in the `packages/mermaid/src/docs` folder and are written in Markdown. Just pick the right section and start typing. - -The contents of [mermaid.js.org](https://mermaid.js.org/) are based on the docs from the `master` branch. -Updates committed to the `master` branch are reflected in the [Mermaid Docs](https://mermaid.js.org/) once published. - -### How to Contribute to Documentation - -We are a little less strict here, it is OK to commit directly in the `develop` branch if you are a collaborator. - -The documentation is located in the `packages/mermaid/src/docs` directory and organized according to relevant subfolder. - -The `docs` folder will be automatically generated when committing to `packages/mermaid/src/docs` and **should not** be edited manually. - -```mermaid -flowchart LR - classDef default fill:#fff,color:black,stroke:black - - source["files in /packages/mermaid/src/docs\n(changes should be done here)"] -- automatic processing\nto generate the final documentation--> published["files in /docs\ndisplayed on the official documentation site"] - -``` - -You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box. -Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly. - -```` -```note -Note content -``` - -```tip -Tip content -``` - -```warning -Warning content -``` - -```danger -Danger content -``` - -```` - -```note -If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. -``` - -We encourage contributions to the documentation at [packages/mermaid/src/docs in the _develop_ branch](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs). - -**_DO NOT CHANGE FILES IN `/docs`_** - -### The official documentation site - -**[The mermaid documentation site](https://mermaid.js.org/) is powered by [Vitepress](https://vitepress.vuejs.org/).** - -To run the documentation site locally: - -1. Run `pnpm --filter mermaid run docs:dev` to start the dev server. (Or `pnpm docs:dev` inside the `packages/mermaid` directory.) -2. Open [http://localhost:3333/](http://localhost:3333/) in your browser. - -Markdown is used to format the text, for more information about Markdown [see the GitHub Markdown help page](https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax). - -To edit Docs on your computer: - -_[TODO: need to keep this in sync with [check out a git branch in Contributing Code above](#1-checkout-a-git-branch) ]_ - -1. Create a fork of the develop branch to work on. -2. Find the Markdown file (.md) to edit in the `packages/mermaid/src/docs` directory. -3. Make changes or add new documentation. -4. Commit changes to your branch and push it to GitHub (which should create a new branch). -5. Create a Pull Request of your fork. - -To edit Docs on GitHub: - -1. Login to [GitHub.com](https://www.github.com). -2. Navigate to [packages/mermaid/src/docs](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs) in the mermaid-js repository. -3. To edit a file, click the pencil icon at the top-right of the file contents panel. -4. Describe what you changed in the **Propose file change** section, located at the bottom of the page. -5. Submit your changes by clicking the button **Propose file change** at the bottom (by automatic creation of a fork and a new branch). -6. Visit the Actions tab in Github, `https://github.com//mermaid/actions` and enable the actions for your fork. This will ensure that the documentation is built and updated in your fork. -7. Create a Pull Request of your newly forked branch by clicking the green **Create Pull Request** button. - -### Documentation organization: Sidebar navigation - -If you want to propose changes to how the documentation is _organized_, such as adding a new section or re-arranging or renaming a section, you must update the **sidebar navigation.** - -The sidebar navigation is defined in [the vitepress configuration file config.ts](../.vitepress/config.ts). - -## Questions or Suggestions? - -#### First search to see if someone has already asked (and hopefully been answered) or suggested the same thing. - -- Search in Discussions -- Search in open Issues -- Search in closed Issues - -If you find an open issue or discussion thread that is similar to your question but isn't answered, you can let us know that you are also interested in it. -Use the GitHub reactions to add a thumbs-up to the issue or discussion thread. - -This helps the team know the relative interest in something and helps them set priorities and assignments. - -Feel free to add to the discussion on the issue or topic. - -If you can't find anything that already addresses your question or suggestion, _open a new issue:_ - -Log in to [GitHub.com](https://www.github.com), open or append to an issue [using the GitHub issue tracker of the mermaid-js repository](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Documentation%22). - -### How to Contribute a Suggestion +All tests should run successfully without any errors or failures. (You might see _lint_ or _formatting_ warnings; those are ok during this step.) ## Last Words diff --git a/packages/mermaid/src/docs/community/docker-development.md b/packages/mermaid/src/docs/community/docker-development.md new file mode 100644 index 000000000..f3fb41391 --- /dev/null +++ b/packages/mermaid/src/docs/community/docker-development.md @@ -0,0 +1,104 @@ +# Contributing to Mermaid via Docker + +> The following documentation describes how to work with Mermaid in a Docker environment. +> There's also a [host installation guide](../community/development.md) +> if you prefer to work without a Docker environment. + +So you want to help? That's great! + +![Image of happy people jumping with excitement](https://media.giphy.com/media/BlVnrxJgTGsUw/giphy.gif) + +Here are a few things to get you started on the right path. + +## Get the Source Code + +In GitHub, you first **fork** a repository when you are going to make changes and submit pull requests. + +Then you **clone** a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with. + +[Fork mermaid](https://github.com/mermaid-js/mermaid/fork) to start contributing to the main project and its documentaion, or [search for other repositories](https://github.com/orgs/mermaid-js/repositories). + +[Here is a GitHub document that gives an overview of the process.](https://docs.github.com/en/get-started/quickstart/fork-a-repo) + +## Technical Requirements + +> The following documentation describes how to work with Mermaid in a Docker environment. +> There's also a [host installation guide](../community/development.md) +> if you prefer to work without a Docker environment. + +[Install Docker](https://docs.docker.com/engine/install/). And that is pretty much all you need. + +Optionally, to run GUI (Cypress) within Docker you will also need X11 server installed. +Maybe you already have it installed, so check it first: + +```bash +echo $DISPLAY +``` + +If variable `$DISPLAY` is not empty, then it must be working. Otherwise install it. + +## Setup and Launch + +### Switch to project + +Once you have cloned the repository onto your development machine, change into the `mermaid` project folder (the top level directory of the mermaid project repository) + +```bash +cd mermaid +``` + +### Make `./run` executable + +For development using Docker there is a self-documented `run` bash script, which provides convenient aliases for `docker compose` commands. + +Ensure `./run` script is executable: + +```bash +chmod +x run +``` + +```tip +To get detailed help simply type `./run` or `./run help`. + +It also has short _Development quick start guide_ embedded. +``` + +### Install packages + +```bash +./run pnpm install # Install packages +``` + +### Launch + +```bash +./run dev +``` + +Now you are ready to make your changes! Edit whichever files in `src` as required. + +Open in your browser, after starting the dev server. +There is a list of demos that can be used to see and test your changes. + +If you need a specific diagram, you can duplicate the `example.html` file in `/demos/dev` and add your own mermaid code to your copy. + +That will be served at . +After making code changes, the dev server will rebuild the mermaid library. You will need to reload the browser page yourself to see the changes. (PRs for auto reload are welcome!) + +## Verify Everything is Working + +```bash +./run pnpm test +``` + +The `test` script and others are in the top-level `package.json` file. + +All tests should run successfully without any errors or failures. (You might see _lint_ or _formatting_ warnings; those are ok during this step.) + +## Last Words + +Don't get daunted if it is hard in the beginning. We have a great community with only encouraging words. So, if you get stuck, ask for help and hints in the Slack forum. If you want to show off something good, show it off there. + +[Join our Slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) + +![Image of superhero wishing you good luck](https://media.giphy.com/media/l49JHz7kJvl6MCj3G/giphy.gif) diff --git a/packages/mermaid/src/docs/community/documentation.md b/packages/mermaid/src/docs/community/documentation.md new file mode 100644 index 000000000..79a984376 --- /dev/null +++ b/packages/mermaid/src/docs/community/documentation.md @@ -0,0 +1,93 @@ +# Contributing Documentation + +**_[TODO: This section is still a WIP. It still needs MAJOR revision.]_** + +If it is not in the documentation, it's like it never happened. Wouldn't that be sad? With all the effort that was put into the feature? + +The docs are located in the `packages/mermaid/src/docs` folder and are written in Markdown. Just pick the right section and start typing. + +The contents of [mermaid.js.org](https://mermaid.js.org/) are based on the docs from the `master` branch. +Updates committed to the `master` branch are reflected in the [Mermaid Docs](https://mermaid.js.org/) once published. + +## How to Contribute to Documentation + +We are a little less strict here, it is OK to commit directly in the `develop` branch if you are a collaborator. + +The documentation is located in the `packages/mermaid/src/docs` directory and organized according to relevant subfolder. + +The `docs` folder will be automatically generated when committing to `packages/mermaid/src/docs` and **should not** be edited manually. + +```mermaid +flowchart LR + classDef default fill:#fff,color:black,stroke:black + + source["files in /packages/mermaid/src/docs\n(changes should be done here)"] -- automatic processing\nto generate the final documentation--> published["files in /docs\ndisplayed on the official documentation site"] + +``` + +You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box. +Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly. + +```` +```note +Note content +``` + +```tip +Tip content +``` + +```warning +Warning content +``` + +```danger +Danger content +``` + +```` + +```note +If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. +``` + +We encourage contributions to the documentation at [packages/mermaid/src/docs in the _develop_ branch](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs). + +**_DO NOT CHANGE FILES IN `/docs`_** + +## The official documentation site + +**[The mermaid documentation site](https://mermaid.js.org/) is powered by [Vitepress](https://vitepress.vuejs.org/).** + +To run the documentation site locally: + +1. Run `pnpm --filter mermaid run docs:dev` to start the dev server. (Or `pnpm docs:dev` inside the `packages/mermaid` directory.) +2. Open [http://localhost:3333/](http://localhost:3333/) in your browser. + +Markdown is used to format the text, for more information about Markdown [see the GitHub Markdown help page](https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax). + +To edit Docs on your computer: + +_[TODO: need to keep this in sync with [check out a git branch in Contributing Code above](#1-checkout-a-git-branch) ]_ + +1. Create a fork of the develop branch to work on. +2. Find the Markdown file (.md) to edit in the `packages/mermaid/src/docs` directory. +3. Make changes or add new documentation. +4. Commit changes to your branch and push it to GitHub (which should create a new branch). +5. Create a Pull Request of your fork. + +To edit Docs on GitHub: + +1. Login to [GitHub.com](https://www.github.com). +2. Navigate to [packages/mermaid/src/docs](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs) in the mermaid-js repository. +3. To edit a file, click the pencil icon at the top-right of the file contents panel. +4. Describe what you changed in the **Propose file change** section, located at the bottom of the page. +5. Submit your changes by clicking the button **Propose file change** at the bottom (by automatic creation of a fork and a new branch). +6. Visit the Actions tab in Github, `https://github.com//mermaid/actions` and enable the actions for your fork. This will ensure that the documentation is built and updated in your fork. +7. Create a Pull Request of your newly forked branch by clicking the green **Create Pull Request** button. + +## Documentation organization: Sidebar navigation + +If you want to propose changes to how the documentation is _organized_, such as adding a new section or re-arranging or renaming a section, you must update the **sidebar navigation.** + +The sidebar navigation is defined in [the vitepress configuration file config.ts](../.vitepress/config.ts). diff --git a/packages/mermaid/src/docs/community/n00b-overview.md b/packages/mermaid/src/docs/community/n00b-overview.md deleted file mode 100644 index e8e84641a..000000000 --- a/packages/mermaid/src/docs/community/n00b-overview.md +++ /dev/null @@ -1,68 +0,0 @@ -# Overview for Beginners - -**Explaining with a Diagram** - -A picture is worth a thousand words, a good diagram is undoubtedly worth more. They make understanding easier. - -## Creating and Maintaining Diagrams - -Anyone who has used Visio, or (God Forbid) Excel to make a Gantt Chart, knows how hard it is to create, edit and maintain good visualizations. - -Diagrams/Charts are significant but also become obsolete/inaccurate very fast. This catch-22 hobbles the productivity of teams. - -# Doc Rot in Diagrams - -Doc-Rot kills diagrams as quickly as it does text, but it takes hours in a desktop application to produce a diagram. - -Mermaid seeks to change using markdown-inspired syntax. The process is a quicker, less complicated, and more convenient way of going from concept to visualization. - -It is a relatively straightforward solution to a significant hurdle with the software teams. - -# Definition of Terms/ Dictionary - -**Mermaid text definitions can be saved for later reuse and editing.** - -> These are the Mermaid diagram definitions inside `
` tags, with the `class=mermaid`. - -```html -
-    graph TD
-    A[Client] --> B[Load Balancer]
-    B --> C[Server01]
-    B --> D[Server02]
-
-``` - -**render** - -> This is the core function of the Mermaid API. It reads all the `Mermaid Definitions` inside `div` tags and returns an SVG file, based on the definition. - -**Nodes** - -> These are the boxes that contain text or otherwise discrete pieces of each diagram, separated generally by arrows, except for Gantt Charts and User Journey Diagrams. They will be referred often in the instructions. Read for Diagram Specific [Syntax](../intro/n00b-syntaxReference.md) - -## Advantages of using Mermaid - -- Ease to generate, modify and render diagrams when you make them. -- The number of integrations and plugins it has. -- You can add it to your or companies website. -- Diagrams can be created through comments like this in a script: - -## The catch-22 of Diagrams and Charts: - -**Diagramming and charting is a large waste of developer's time, but not having diagrams ruins productivity.** - -Mermaid solves this by reducing the time and effort required to create diagrams and charts. - -Because, the text base for the diagrams allows it to be updated easily. Also, it can be made part of production scripts (and other pieces of code). So less time is spent on documenting, as a separate task. - -## Catching up with Development - -Being based on markdown, Mermaid can be used, not only by accomplished front-end developers, but by most computer savvy people to render diagrams, at much faster speeds. -In fact one can pick up the syntax for it quite easily from the examples given and there are many tutorials available in the internet. - -## Mermaid is for everyone. - -Video [Tutorials](https://mermaid.js.org/config/Tutorials.html) are also available for the mermaid [live editor](https://mermaid.live/). - -Alternatively you can use Mermaid [Plug-Ins](https://mermaid-js.github.io/mermaid/#/./integrations), with tools you already use, like Google Docs. diff --git a/packages/mermaid/src/docs/community/questionsAndSuggestions.md b/packages/mermaid/src/docs/community/questionsAndSuggestions.md new file mode 100644 index 000000000..f72d0a47d --- /dev/null +++ b/packages/mermaid/src/docs/community/questionsAndSuggestions.md @@ -0,0 +1,22 @@ +# Questions or Suggestions? + +**_[TODO: This section is still a WIP. It still needs MAJOR revision.]_** + +## First search to see if someone has already asked (and hopefully been answered) or suggested the same thing. + +- Search in Discussions +- Search in open Issues +- Search in closed Issues + +If you find an open issue or discussion thread that is similar to your question but isn't answered, you can let us know that you are also interested in it. +Use the GitHub reactions to add a thumbs-up to the issue or discussion thread. + +This helps the team know the relative interest in something and helps them set priorities and assignments. + +Feel free to add to the discussion on the issue or topic. + +If you can't find anything that already addresses your question or suggestion, _open a new issue:_ + +Log in to [GitHub.com](https://www.github.com), open or append to an issue [using the GitHub issue tracker of the mermaid-js repository](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Documentation%22). + +## How to Contribute a Suggestion diff --git a/packages/mermaid/src/docs/intro/index.md b/packages/mermaid/src/docs/intro/index.md index c81cd0efc..61fd064ec 100644 --- a/packages/mermaid/src/docs/intro/index.md +++ b/packages/mermaid/src/docs/intro/index.md @@ -99,6 +99,7 @@ To Deploy Mermaid: - [Mermaid CLI](https://github.com/mermaid-js/mermaid-cli) - [Mermaid Webpack Demo](https://github.com/mermaidjs/mermaid-webpack-demo) - [Mermaid Parcel Demo](https://github.com/mermaidjs/mermaid-parcel-demo) +- [HTTP Server](https://github.com/TomWright/mermaid-server) ## Request for Assistance @@ -115,7 +116,17 @@ Together we could continue the work with things like: Don't hesitate to contact me if you want to get involved! -## For contributors +## Contributors + +
+ +[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) [![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) [![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) + +
+ +Mermaid is a growing community and is always accepting new contributors. There's a lot of different ways to help out and we're always looking for extra hands! Look at [this issue](https://github.com/mermaid-js/mermaid/issues/866) if you want to know where to start helping out. + +Detailed information about how to contribute can be found in the [contribution guideline](/community/development). ### Requirements @@ -123,7 +134,7 @@ Don't hesitate to contact me if you want to get involved! - [Node.js](https://nodejs.org/en/). `volta install node` - [pnpm](https://pnpm.io/) package manager. `volta install pnpm` -## Development Installation +### Development Installation ```bash git clone git@github.com:mermaid-js/mermaid.git @@ -160,25 +171,7 @@ Update version number in `package.json`. npm publish ``` -The above command generates files into the `dist` folder and publishes them to . - -## Related projects - -- [Command Line Interface](https://github.com/mermaid-js/mermaid-cli) -- [Live Editor](https://github.com/mermaid-js/mermaid-live-editor) -- [HTTP Server](https://github.com/TomWright/mermaid-server) - -## Contributors - -
- -[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) [![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) [![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) - -
- -Mermaid is a growing community and is always accepting new contributors. There's a lot of different ways to help out and we're always looking for extra hands! Look at [this issue](https://github.com/mermaid-js/mermaid/issues/866) if you want to know where to start helping out. - -Detailed information about how to contribute can be found in the [contribution guide](https://github.com/mermaid-js/mermaid/blob/develop/CONTRIBUTING.md) +The above command generates files into the `dist` folder and publishes them to [npmjs.org](npmjs.org). ## Security and safe diagrams diff --git a/packages/mermaid/src/docs/intro/n00b-syntaxReference.md b/packages/mermaid/src/docs/intro/n00b-syntaxReference.md index 8e8c18a4d..398f83257 100644 --- a/packages/mermaid/src/docs/intro/n00b-syntaxReference.md +++ b/packages/mermaid/src/docs/intro/n00b-syntaxReference.md @@ -38,11 +38,11 @@ One should **beware the use of some words or symbols** that can break diagrams. | 'end' | The word "End" can cause Flowcharts and Sequence diagrams to break | Wrap them in quotation marks to prevent breakage. | | [Nodes inside Nodes](../syntax/flowchart.md?id=special-characters-that-break-syntax) | Mermaid gets confused with nested shapes | wrap them in quotation marks to prevent breaking | -### Mermaid Live Editor +## Mermaid Live Editor Now, that you've seen what you should not add to your diagrams, you can play around with them in the [Mermaid Live Editor](https://mermaid.live). -# Configuration +## Configuration Configuration is the third part of Mermaid, after deployment and syntax. It deals with the different ways that Mermaid can be customized across different deployments. diff --git a/run b/run index cc169e209..fbf437263 100755 --- a/run +++ b/run @@ -80,6 +80,9 @@ $(bold ./$name cypress open --project .) $(bold ./$name cypress run --spec cypress/integration/rendering/)$(underline test.spec.ts) Run specific test in cypress\n +$(bold xhost +local:) + Allow local connections for x11 server + EOF ) From 7b45dbea1a74f46b136d3b7bcd4c001f685312cf Mon Sep 17 00:00:00 2001 From: Nikolay Rozhkov Date: Fri, 18 Aug 2023 03:14:12 +0300 Subject: [PATCH 03/70] Fixed links --- docs/intro/index.md | 2 +- packages/mermaid/src/docs/intro/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/intro/index.md b/docs/intro/index.md index 89af6ecd1..b77dd454f 100644 --- a/docs/intro/index.md +++ b/docs/intro/index.md @@ -37,7 +37,7 @@ Mermaid allows even non-programmers to easily create detailed and diagrams throu [Tutorials](../config/Tutorials.md) has video tutorials. Use Mermaid with your favorite applications, check out the list of [Integrations and Usages of Mermaid](../ecosystem/integrations.md). -For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](../community/n00b-overview.md) and [Usage](../config/usage.md). +For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](../intro/n00b-gettingStarted.md) and [Usage](../config/usage.md). 🌐 [CDN](https://www.jsdelivr.com/package/npm/mermaid) | 📖 [Documentation](https://mermaidjs.github.io) | 🙌 [Contribution](../community/development.md) | 🔌 [Plug-Ins](../ecosystem/integrations.md) diff --git a/packages/mermaid/src/docs/intro/index.md b/packages/mermaid/src/docs/intro/index.md index 61fd064ec..c76f09a08 100644 --- a/packages/mermaid/src/docs/intro/index.md +++ b/packages/mermaid/src/docs/intro/index.md @@ -32,7 +32,7 @@ Mermaid allows even non-programmers to easily create detailed and diagrams throu [Tutorials](../config/Tutorials.md) has video tutorials. Use Mermaid with your favorite applications, check out the list of [Integrations and Usages of Mermaid](../ecosystem/integrations.md). -For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](../community/n00b-overview.md) and [Usage](../config/usage.md). +For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](../intro/n00b-gettingStarted.md) and [Usage](../config/usage.md). 🌐 [CDN](https://www.jsdelivr.com/package/npm/mermaid) | 📖 [Documentation](https://mermaidjs.github.io) | 🙌 [Contribution](../community/development.md) | 🔌 [Plug-Ins](../ecosystem/integrations.md) From 4d84f1cd71eba0b1aa0e544e05c47e45c9355939 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 19 Aug 2023 11:19:18 +0530 Subject: [PATCH 04/70] feat(sankey): Show values (#4674) --- demos/sankey.html | 32 +++++++++++++++---- packages/mermaid/src/config.type.ts | 15 +++++++++ .../mermaid/src/diagrams/sankey/sankeyDB.ts | 2 +- .../src/diagrams/sankey/sankeyRenderer.ts | 26 ++++++++++----- .../mermaid/src/schemas/config.schema.yaml | 14 ++++++++ 5 files changed, 74 insertions(+), 15 deletions(-) diff --git a/demos/sankey.html b/demos/sankey.html index 0c9679c65..4c3eeac5e 100644 --- a/demos/sankey.html +++ b/demos/sankey.html @@ -5,16 +5,13 @@ States Mermaid Quick Test Page -

Sankey diagram demos

+

FY20-21 Performance

+
+

Energy flow

       sankey-beta
@@ -101,8 +98,31 @@
           height: 600,
           linkColor: 'gradient',
           nodeAlignment: 'justify',
+          showValues: false,
+        },
+        startOnLoad: false,
+      });
+      // Render the Energy flow diagram
+      await mermaid.run();
+
+      mermaid.initialize({
+        sankey: {
+          prefix: '$',
+          suffix: 'B',
         },
       });
+
+      const { svg } = await mermaid.render(
+        'ff',
+        `
+sankey-beta
+Revenue,Expenses,10
+Revenue,Profit,10
+Expenses,Manufacturing,5
+Expenses,Tax,3
+Expenses,Research,2`
+      );
+      document.getElementById('financials').innerHTML = svg;
     
   
 
diff --git a/packages/mermaid/src/config.type.ts b/packages/mermaid/src/config.type.ts
index c378660ca..a4bf6cca8 100644
--- a/packages/mermaid/src/config.type.ts
+++ b/packages/mermaid/src/config.type.ts
@@ -1298,6 +1298,21 @@ export interface SankeyDiagramConfig extends BaseDiagramConfig {
    */
   nodeAlignment?: 'left' | 'right' | 'center' | 'justify';
   useMaxWidth?: boolean;
+  /**
+   * Toggle to display or hide values along with title.
+   *
+   */
+  showValues?: boolean;
+  /**
+   * The prefix to use for values
+   *
+   */
+  prefix?: string;
+  /**
+   * The suffix to use for values
+   *
+   */
+  suffix?: string;
 }
 /**
  * This interface was referenced by `MermaidConfig`'s JSON-Schema
diff --git a/packages/mermaid/src/diagrams/sankey/sankeyDB.ts b/packages/mermaid/src/diagrams/sankey/sankeyDB.ts
index 1921e1b85..f6db1886d 100644
--- a/packages/mermaid/src/diagrams/sankey/sankeyDB.ts
+++ b/packages/mermaid/src/diagrams/sankey/sankeyDB.ts
@@ -31,7 +31,7 @@ class SankeyLink {
 /**
  * @param source - Node where the link starts
  * @param target - Node where the link ends
- * @param value - number, float or integer, describes the amount to be passed
+ * @param value - Describes the amount to be passed
  */
 const addLink = (source: SankeyNode, target: SankeyNode, value: number): void => {
   links.push(new SankeyLink(source, target, value));
diff --git a/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts b/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts
index a9ee698e9..c40226b4c 100644
--- a/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts
+++ b/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts
@@ -18,7 +18,7 @@ import {
 } from 'd3-sankey';
 import { configureSvgSize } from '../../setupGraphViewbox.js';
 import { Uid } from '../../rendering-util/uid.js';
-import type { SankeyLinkColor, SankeyNodeAlignment } from '../../config.type.js';
+import type { SankeyNodeAlignment } from '../../config.type.js';
 
 // Map config options to alignment functions
 const alignmentsMap: Record<
@@ -62,10 +62,13 @@ export const draw = function (text: string, id: string, _version: string, diagOb
 
   // Establish svg dimensions and get width and height
   //
-  const width = conf?.width || defaultSankeyConfig.width!;
-  const height = conf?.height || defaultSankeyConfig.width!;
-  const useMaxWidth = conf?.useMaxWidth || defaultSankeyConfig.useMaxWidth!;
-  const nodeAlignment = conf?.nodeAlignment || defaultSankeyConfig.nodeAlignment!;
+  const width = conf?.width ?? defaultSankeyConfig.width!;
+  const height = conf?.height ?? defaultSankeyConfig.width!;
+  const useMaxWidth = conf?.useMaxWidth ?? defaultSankeyConfig.useMaxWidth!;
+  const nodeAlignment = conf?.nodeAlignment ?? defaultSankeyConfig.nodeAlignment!;
+  const prefix = conf?.prefix ?? defaultSankeyConfig.prefix!;
+  const suffix = conf?.suffix ?? defaultSankeyConfig.suffix!;
+  const showValues = conf?.showValues ?? defaultSankeyConfig.showValues!;
 
   // FIX: using max width prevents height from being set, is it intended?
   // to add height directly one can use `svg.attr('height', height)`
@@ -94,7 +97,7 @@ export const draw = function (text: string, id: string, _version: string, diagOb
   const sankey = d3Sankey()
     .nodeId((d: any) => d.id) // we use 'id' property to identify node
     .nodeWidth(nodeWidth)
-    .nodePadding(10)
+    .nodePadding(10 + (showValues ? 15 : 0))
     .nodeAlign(nodeAlign)
     .extent([
       [0, 0],
@@ -130,6 +133,13 @@ export const draw = function (text: string, id: string, _version: string, diagOb
     .attr('width', (d: any) => d.x1 - d.x0)
     .attr('fill', (d: any) => colorScheme(d.id));
 
+  const getText = ({ id, value }: { id: string; value: number }) => {
+    if (!showValues) {
+      return id;
+    }
+    return `${id}\n${prefix}${Math.round(value * 100) / 100}${suffix}`;
+  };
+
   // Create labels for nodes
   svg
     .append('g')
@@ -141,9 +151,9 @@ export const draw = function (text: string, id: string, _version: string, diagOb
     .join('text')
     .attr('x', (d: any) => (d.x0 < width / 2 ? d.x1 + 6 : d.x0 - 6))
     .attr('y', (d: any) => (d.y1 + d.y0) / 2)
-    .attr('dy', '0.35em')
+    .attr('dy', `${showValues ? '0' : '0.35'}em`)
     .attr('text-anchor', (d: any) => (d.x0 < width / 2 ? 'start' : 'end'))
-    .text((d: any) => d.id);
+    .text(getText);
 
   // Creates the paths that represent the links.
   const link = svg
diff --git a/packages/mermaid/src/schemas/config.schema.yaml b/packages/mermaid/src/schemas/config.schema.yaml
index 6e5f48d95..9e7b3e6f3 100644
--- a/packages/mermaid/src/schemas/config.schema.yaml
+++ b/packages/mermaid/src/schemas/config.schema.yaml
@@ -1859,6 +1859,20 @@ $defs: # JSON Schema definition (maybe we should move these to a seperate file)
         default: justify
       useMaxWidth:
         default: false
+      showValues:
+        description: |
+          Toggle to display or hide values along with title.
+        default: true
+      prefix:
+        description: |
+          The prefix to use for values
+        type: string
+        default: ''
+      suffix:
+        description: |
+          The suffix to use for values
+        type: string
+        default: ''
 
   FontCalculator:
     title: Font Calculator

From 7a547abd896ee906a277167ecdb27af4cc5d71e9 Mon Sep 17 00:00:00 2001
From: Alois Klink 
Date: Sun, 20 Aug 2023 23:42:18 +0100
Subject: [PATCH 05/70] ci(release-drafter): add more release notes categories

Add the following new categories to the release notes:
  - **BREAKING CHANGES**
  - Performance
  - Documentation

I've also made the `feature`, `fix`, and `chore` label point to
their appropriate section.
---
 .github/release-drafter.yml | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml
index 278151bca..e650f8dd1 100644
--- a/.github/release-drafter.yml
+++ b/.github/release-drafter.yml
@@ -1,14 +1,27 @@
 name-template: '$NEXT_PATCH_VERSION'
 tag-template: '$NEXT_PATCH_VERSION'
 categories:
+  - title: '🚨 **Breaking Changes**'
+    labels:
+      - 'Breaking Change'
   - title: '🚀 Features'
     labels:
       - 'Type: Enhancement'
+      - 'feature' # deprecated, new PRs shouldn't have this
   - title: '🐛 Bug Fixes'
     labels:
       - 'Type: Bug / Error'
+      - 'fix' # deprecated, new PRs shouldn't have this
   - title: '🧰 Maintenance'
-    label: 'Type: Other'
+    labels:
+      - 'Type: Other'
+      - 'chore' # deprecated, new PRs shouldn't have this
+  - title: '⚡️ Performance'
+    labels:
+      - 'Type: Performance'
+  - title: '📚 Documentation'
+    labels:
+      - 'Area: Documentation'
 change-template: '- $TITLE (#$NUMBER) @$AUTHOR'
 sort-by: title
 sort-direction: ascending

From 1d64549ccebec90db1623e59b97670735dcd687c Mon Sep 17 00:00:00 2001
From: Reda Al Sulais 
Date: Mon, 21 Aug 2023 02:38:23 +0300
Subject: [PATCH 06/70] fix(mermaid): mark `mermaid-parser` dependecy with `^`

Co-authored-by: Alois Klink 
---
 packages/mermaid/package.json |  2 +-
 pnpm-lock.yaml                | 54 +----------------------------------
 2 files changed, 2 insertions(+), 54 deletions(-)

diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json
index 5a1aa98a0..e0a7611e1 100644
--- a/packages/mermaid/package.json
+++ b/packages/mermaid/package.json
@@ -71,7 +71,7 @@
     "khroma": "^2.0.0",
     "lodash-es": "^4.17.21",
     "mdast-util-from-markdown": "^1.3.0",
-    "mermaid-parser": "workspace:*",
+    "mermaid-parser": "workspace:^",
     "stylis": "^4.1.3",
     "ts-dedent": "^2.2.0",
     "uuid": "^9.0.0"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 77c9a808c..7f6e1a9d3 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -234,7 +234,7 @@ importers:
         specifier: ^1.3.0
         version: 1.3.0
       mermaid-parser:
-        specifier: workspace:*
+        specifier: workspace:^
         version: link:../parser
       stylis:
         specifier: ^4.1.3
@@ -475,58 +475,6 @@ importers:
         specifier: ^7.0.0
         version: 7.0.0
 
-  packages/mermaid/src/vitepress:
-    dependencies:
-      '@vueuse/core':
-        specifier: ^10.1.0
-        version: 10.1.0(vue@3.3.0)
-      jiti:
-        specifier: ^1.18.2
-        version: 1.18.2
-      vue:
-        specifier: ^3.3
-        version: 3.3.0
-    devDependencies:
-      '@iconify-json/carbon':
-        specifier: ^1.1.16
-        version: 1.1.16
-      '@unocss/reset':
-        specifier: ^0.55.0
-        version: 0.55.0
-      '@vite-pwa/vitepress':
-        specifier: ^0.2.0
-        version: 0.2.0(vite-plugin-pwa@0.16.0)
-      '@vitejs/plugin-vue':
-        specifier: ^4.2.1
-        version: 4.2.1(vite@4.3.9)(vue@3.3.0)
-      fast-glob:
-        specifier: ^3.2.12
-        version: 3.2.12
-      https-localhost:
-        specifier: ^4.7.1
-        version: 4.7.1
-      pathe:
-        specifier: ^1.1.0
-        version: 1.1.0
-      unocss:
-        specifier: ^0.55.0
-        version: 0.55.0(postcss@8.4.28)(rollup@2.79.1)(vite@4.3.9)
-      unplugin-vue-components:
-        specifier: ^0.25.0
-        version: 0.25.0(rollup@2.79.1)(vue@3.3.0)
-      vite:
-        specifier: ^4.3.9
-        version: 4.3.9(@types/node@18.16.0)
-      vite-plugin-pwa:
-        specifier: ^0.16.0
-        version: 0.16.0(vite@4.3.9)(workbox-build@7.0.0)(workbox-window@7.0.0)
-      vitepress:
-        specifier: 1.0.0-rc.4
-        version: 1.0.0-rc.4(@algolia/client-search@4.19.1)(@types/node@18.16.0)(search-insights@2.7.0)
-      workbox-window:
-        specifier: ^7.0.0
-        version: 7.0.0
-
   packages/parser:
     dependencies:
       langium:

From 83e47a7216cdb82373df1efc14ca630bb5b0c644 Mon Sep 17 00:00:00 2001
From: Reda Al Sulais 
Date: Mon, 21 Aug 2023 02:54:30 +0300
Subject: [PATCH 07/70] fix: use `execFileSync` instead of `execSync` in
 `generateLangium`

---
 .build/generateLangium.ts | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/.build/generateLangium.ts b/.build/generateLangium.ts
index c44d643b8..7c171a11c 100644
--- a/.build/generateLangium.ts
+++ b/.build/generateLangium.ts
@@ -1,5 +1,11 @@
-import { execSync } from 'child_process';
+import { execFileSync } from 'child_process';
 
 export function generateLangium() {
-  execSync(`pnpm --prefix ${process.cwd()}/packages/parser exec langium generate`);
+  execFileSync('pnpm', [
+    '--prefix',
+    `${process.cwd()}/packages/parser`,
+    'exec',
+    'langium',
+    'generate',
+  ]);
 }

From cc6f896b69423609126b947bdd457017629c3158 Mon Sep 17 00:00:00 2001
From: Reda Al Sulais 
Date: Mon, 21 Aug 2023 03:03:50 +0300
Subject: [PATCH 08/70] chore: remove `./*` part from `exports` in
 `parser/package.json`

Co-authored-by: Alois Klink 
---
 packages/parser/package.json | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/packages/parser/package.json b/packages/parser/package.json
index 6ee9c07bf..e8bb1d529 100644
--- a/packages/parser/package.json
+++ b/packages/parser/package.json
@@ -14,8 +14,7 @@
     ".": {
       "import": "./dist/mermaid-parser.esm.mjs",
       "types": "./dist/src/index.d.ts"
-    },
-    "./*": "./*"
+    }
   },
   "scripts": {
     "clean": "rimraf dist src/language/generated",

From eb63568ceb76854c89ccf79e58c31e6567c2962f Mon Sep 17 00:00:00 2001
From: Reda Al Sulais 
Date: Mon, 21 Aug 2023 03:04:39 +0300
Subject: [PATCH 09/70] chore: refactore `&&` into `if` in `populateCommonDb`

---
 .../mermaid/src/diagrams/common/populateCommonDb.ts  | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/packages/mermaid/src/diagrams/common/populateCommonDb.ts b/packages/mermaid/src/diagrams/common/populateCommonDb.ts
index f0e4dcdb3..dd8610dce 100644
--- a/packages/mermaid/src/diagrams/common/populateCommonDb.ts
+++ b/packages/mermaid/src/diagrams/common/populateCommonDb.ts
@@ -3,7 +3,13 @@ import type { DiagramAST } from 'mermaid-parser';
 import type { DiagramDB } from '../../diagram-api/types.js';
 
 export function populateCommonDb(ast: DiagramAST, db: DiagramDB) {
-  ast.accDescr && db.setAccDescription?.(ast.accDescr);
-  ast.accTitle && db.setAccTitle?.(ast.accTitle);
-  ast.title && db.setDiagramTitle?.(ast.title);
+  if (ast.accDescr) {
+    db.setAccDescription?.(ast.accDescr);
+  }
+  if (ast.accTitle) {
+    db.setAccTitle?.(ast.accTitle);
+  }
+  if (ast.title) {
+    db.setDiagramTitle?.(ast.title);
+  }
 }

From 984a0e6d06826a449789284ceb9e5744ffcb9772 Mon Sep 17 00:00:00 2001
From: Reda Al Sulais 
Date: Mon, 21 Aug 2023 03:05:23 +0300
Subject: [PATCH 10/70] chore: add a comment illustrate why we build packages
 sequentially

---
 .esbuild/build.ts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.esbuild/build.ts b/.esbuild/build.ts
index 3b34b8b44..28b841341 100644
--- a/.esbuild/build.ts
+++ b/.esbuild/build.ts
@@ -56,6 +56,7 @@ const main = async () => {
   generateLangium();
   await mkdir('stats').catch(() => {});
   const packageNames = Object.keys(packageOptions) as (keyof typeof packageOptions)[];
+  // it should build `parser` before `mermaid` because it's a dependecy
   for (const pkg of packageNames) {
     await buildPackage(pkg).catch(handler);
   }

From 205360c1093ad0059989e05d5efecc4f019225b7 Mon Sep 17 00:00:00 2001
From: Reda Al Sulais 
Date: Mon, 21 Aug 2023 03:09:05 +0300
Subject: [PATCH 11/70] fix: fix if statment logic checks if `parser` is not
 `undefined`

---
 packages/mermaid/src/Diagram.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/mermaid/src/Diagram.ts b/packages/mermaid/src/Diagram.ts
index 1d4793bf0..941ada0f8 100644
--- a/packages/mermaid/src/Diagram.ts
+++ b/packages/mermaid/src/Diagram.ts
@@ -50,7 +50,7 @@ export class Diagram {
     this.parser.parse = (text: string) =>
       originalParse(cleanupComments(extractFrontMatter(text, this.db)));
 
-    if (this.parser.parser?.yy) {
+    if (this.parser.parser !== undefined) {
       this.parser.parser.yy = this.db;
     }
     this.init = diagram.init;

From 21d0998db88238ac37a350f53751d9341b71fed7 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Mon, 21 Aug 2023 03:01:21 +0000
Subject: [PATCH 12/70] chore(deps): update all patch dependencies

---
 docker-compose.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docker-compose.yml b/docker-compose.yml
index 56a46e84c..2480311a2 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -17,7 +17,7 @@ services:
       - 9000:9000
       - 3333:3333
   cypress:
-    image: cypress/included:12.17.3
+    image: cypress/included:12.17.4
     stdin_open: true
     tty: true
     working_dir: /mermaid

From fae976e994a30336878444e148ed1ac19ca331f6 Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Mon, 21 Aug 2023 10:13:48 +0530
Subject: [PATCH 13/70] refactor: Rename and cleanup `directiveSanitizer`

---
 packages/mermaid/src/defaultConfig.ts |  2 +-
 packages/mermaid/src/utils.ts         | 97 +++++++++++++--------------
 2 files changed, 47 insertions(+), 52 deletions(-)

diff --git a/packages/mermaid/src/defaultConfig.ts b/packages/mermaid/src/defaultConfig.ts
index 0b232116d..f8bd9b0b5 100644
--- a/packages/mermaid/src/defaultConfig.ts
+++ b/packages/mermaid/src/defaultConfig.ts
@@ -265,5 +265,5 @@ const keyify = (obj: any, prefix = ''): string[] =>
     return [...res, prefix + el];
   }, []);
 
-export const configKeys: string[] = keyify(config, '');
+export const configKeys: Set = new Set(keyify(config, ''));
 export default config;
diff --git a/packages/mermaid/src/utils.ts b/packages/mermaid/src/utils.ts
index 937f3f8f8..f054ef29f 100644
--- a/packages/mermaid/src/utils.ts
+++ b/packages/mermaid/src/utils.ts
@@ -102,7 +102,7 @@ export const detectInit = function (text: string, config?: MermaidConfig): Merma
 
   if (Array.isArray(inits)) {
     const args = inits.map((init) => init.args);
-    directiveSanitizer(args);
+    sanitizeDirective(args);
 
     results = assignWithDepth(results, [...args]);
   } else {
@@ -842,67 +842,62 @@ export const entityDecode = function (html: string): string {
  *
  * @param args - Directive's JSON
  */
-export const directiveSanitizer = (args: any) => {
-  log.debug('directiveSanitizer called with', args);
-  if (typeof args === 'object') {
-    // check for array
-    if (args.length) {
-      args.forEach((arg) => directiveSanitizer(arg));
-    } else {
-      // This is an object
-      Object.keys(args).forEach((key) => {
-        log.debug('Checking key', key);
-        if (key.startsWith('__')) {
-          log.debug('sanitize deleting __ option', key);
-          delete args[key];
-        }
+export const sanitizeDirective = (args: unknown): void => {
+  log.debug('sanitizeDirective called with', args);
 
-        if (key.includes('proto')) {
-          log.debug('sanitize deleting proto option', key);
-          delete args[key];
-        }
+  // Return if not an object
+  if (typeof args !== 'object') {
+    return;
+  }
 
-        if (key.includes('constr')) {
-          log.debug('sanitize deleting constr option', key);
-          delete args[key];
-        }
+  // Sanitize each element if an array
+  if (Array.isArray(args)) {
+    args.forEach((arg) => sanitizeDirective(arg));
+    return;
+  }
 
-        if (key.includes('themeCSS')) {
-          log.debug('sanitizing themeCss option');
-          args[key] = sanitizeCss(args[key]);
-        }
-        if (key.includes('fontFamily')) {
-          log.debug('sanitizing fontFamily option');
-          args[key] = sanitizeCss(args[key]);
-        }
-        if (key.includes('altFontFamily')) {
-          log.debug('sanitizing altFontFamily option');
-          args[key] = sanitizeCss(args[key]);
-        }
-        if (!configKeys.includes(key)) {
-          log.debug('sanitize deleting option', key);
-          delete args[key];
-        } else {
-          if (typeof args[key] === 'object') {
-            log.debug('sanitize deleting object', key);
-            directiveSanitizer(args[key]);
-          }
-        }
-      });
+  // Sanitize each key if an object
+  for (const key of Object.keys(args)) {
+    log.debug('Checking key', key);
+    if (
+      key.startsWith('__') ||
+      key.includes('proto') ||
+      key.includes('constr') ||
+      !configKeys.has(key)
+    ) {
+      log.debug('sanitize deleting key: ', key);
+      delete args[key];
+      continue;
+    }
+
+    // Recurse if an object
+    if (typeof args[key] === 'object') {
+      log.debug('sanitizing object', key);
+      sanitizeDirective(args[key]);
+      continue;
+    }
+
+    const cssMatchers = ['themeCSS', 'fontFamily', 'altFontFamily'];
+    for (const cssKey of cssMatchers) {
+      if (key.includes(cssKey)) {
+        log.debug('sanitizing css option', key);
+        args[key] = sanitizeCss(args[key]);
+      }
     }
   }
+
   if (args.themeVariables) {
-    const kArr = Object.keys(args.themeVariables);
-    for (const k of kArr) {
+    for (const k of Object.keys(args.themeVariables)) {
       const val = args.themeVariables[k];
-      if (val && val.match && !val.match(/^[\d "#%(),.;A-Za-z]+$/)) {
+      if (val?.match && !val.match(/^[\d "#%(),.;A-Za-z]+$/)) {
         args.themeVariables[k] = '';
       }
     }
   }
   log.debug('After sanitization', args);
 };
-export const sanitizeCss = (str) => {
+
+export const sanitizeCss = (str: string): string => {
   let startCnt = 0;
   let endCnt = 0;
 
@@ -1019,8 +1014,8 @@ export default {
   random,
   runFunc,
   entityDecode,
-  initIdGenerator: initIdGenerator,
-  directiveSanitizer,
+  initIdGenerator,
+  sanitizeDirective,
   sanitizeCss,
   insertTitle,
   parseFontSize,

From f422a66dde10ccbfd4716c4e62801d17a9679ea2 Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Mon, 21 Aug 2023 10:17:55 +0530
Subject: [PATCH 14/70] refactor: Move `sanitizeDirective` into `addDirective`

---
 packages/mermaid/src/config.spec.ts    | 27 ++++++++++++++++---------
 packages/mermaid/src/config.ts         | 28 +++++++++-----------------
 packages/mermaid/src/directiveUtils.ts |  5 -----
 packages/mermaid/src/mermaidAPI.ts     |  3 +--
 packages/mermaid/src/utils.ts          |  2 --
 5 files changed, 29 insertions(+), 36 deletions(-)

diff --git a/packages/mermaid/src/config.spec.ts b/packages/mermaid/src/config.spec.ts
index 457cb8244..8dd4ff33c 100644
--- a/packages/mermaid/src/config.spec.ts
+++ b/packages/mermaid/src/config.spec.ts
@@ -1,11 +1,13 @@
+/* eslint-disable @typescript-eslint/no-non-null-assertion */
 import * as configApi from './config.js';
+import type { MermaidConfig } from './config.type.js';
 
-describe('when working with site config', function () {
+describe('when working with site config', () => {
   beforeEach(() => {
     // Resets the site config to default config
     configApi.setSiteConfig({});
   });
-  it('should set site config and config properly', function () {
+  it('should set site config and config properly', () => {
     const config_0 = { fontFamily: 'foo-font', fontSize: 150 };
     configApi.setSiteConfig(config_0);
     const config_1 = configApi.getSiteConfig();
@@ -14,19 +16,26 @@ describe('when working with site config', function () {
     expect(config_1.fontSize).toEqual(config_0.fontSize);
     expect(config_1).toEqual(config_2);
   });
-  it('should respect secure keys when applying directives', function () {
-    const config_0 = {
+  it('should respect secure keys when applying directives', () => {
+    const config_0: MermaidConfig = {
       fontFamily: 'foo-font',
+      securityLevel: 'strict', // can't be changed
       fontSize: 12345, // can't be changed
       secure: [...configApi.defaultConfig.secure!, 'fontSize'],
     };
     configApi.setSiteConfig(config_0);
-    const directive = { fontFamily: 'baf', fontSize: 54321 /* fontSize shouldn't be changed */ };
-    const cfg = configApi.updateCurrentConfig(config_0, [directive]);
+    const directive: MermaidConfig = {
+      fontFamily: 'baf',
+      // fontSize and securityLevel shouldn't be changed
+      fontSize: 54321,
+      securityLevel: 'loose',
+    };
+    const cfg: MermaidConfig = configApi.updateCurrentConfig(config_0, [directive]);
     expect(cfg.fontFamily).toEqual(directive.fontFamily);
     expect(cfg.fontSize).toBe(config_0.fontSize);
+    expect(cfg.securityLevel).toBe(config_0.securityLevel);
   });
-  it('should allow setting partial options', function () {
+  it('should allow setting partial options', () => {
     const defaultConfig = configApi.getConfig();
 
     configApi.setConfig({
@@ -42,7 +51,7 @@ describe('when working with site config', function () {
       updatedConfig.quadrantChart!.chartWidth
     );
   });
-  it('should set reset config properly', function () {
+  it('should set reset config properly', () => {
     const config_0 = { fontFamily: 'foo-font', fontSize: 150 };
     configApi.setSiteConfig(config_0);
     const config_1 = { fontFamily: 'baf' };
@@ -55,7 +64,7 @@ describe('when working with site config', function () {
     const config_4 = configApi.getSiteConfig();
     expect(config_4.fontFamily).toEqual(config_0.fontFamily);
   });
-  it('should set global reset config properly', function () {
+  it('should set global reset config properly', () => {
     const config_0 = { fontFamily: 'foo-font', fontSize: 150 };
     configApi.setSiteConfig(config_0);
     const config_1 = configApi.getSiteConfig();
diff --git a/packages/mermaid/src/config.ts b/packages/mermaid/src/config.ts
index e00663827..c426e9122 100644
--- a/packages/mermaid/src/config.ts
+++ b/packages/mermaid/src/config.ts
@@ -3,15 +3,16 @@ import { log } from './logger.js';
 import theme from './themes/index.js';
 import config from './defaultConfig.js';
 import type { MermaidConfig } from './config.type.js';
+import { sanitizeDirective } from './utils.js';
 
 export const defaultConfig: MermaidConfig = Object.freeze(config);
 
 let siteConfig: MermaidConfig = assignWithDepth({}, defaultConfig);
 let configFromInitialize: MermaidConfig;
-let directives: any[] = [];
+let directives: MermaidConfig[] = [];
 let currentConfig: MermaidConfig = assignWithDepth({}, defaultConfig);
 
-export const updateCurrentConfig = (siteCfg: MermaidConfig, _directives: any[]) => {
+export const updateCurrentConfig = (siteCfg: MermaidConfig, _directives: MermaidConfig[]) => {
   // start with config being the siteConfig
   let cfg: MermaidConfig = assignWithDepth({}, siteCfg);
   // let sCfg = assignWithDepth(defaultConfig, siteConfigDelta);
@@ -20,7 +21,6 @@ export const updateCurrentConfig = (siteCfg: MermaidConfig, _directives: any[])
   let sumOfDirectives: MermaidConfig = {};
   for (const d of _directives) {
     sanitize(d);
-
     // Apply the data from the directive where the the overrides the themeVariables
     sumOfDirectives = assignWithDepth(sumOfDirectives, d);
   }
@@ -111,12 +111,6 @@ export const getSiteConfig = (): MermaidConfig => {
  * @returns The currentConfig merged with the sanitized conf
  */
 export const setConfig = (conf: MermaidConfig): MermaidConfig => {
-  // sanitize(conf);
-  // Object.keys(conf).forEach(key => {
-  //   const manipulator = manipulators[key];
-  //   conf[key] = manipulator ? manipulator(conf[key]) : conf[key];
-  // });
-
   checkConfig(conf);
   assignWithDepth(currentConfig, conf);
 
@@ -188,16 +182,14 @@ export const sanitize = (options: any) => {
  *
  * @param directive - The directive to push in
  */
-export const addDirective = (directive: any) => {
-  if (directive.fontFamily) {
-    if (!directive.themeVariables) {
-      directive.themeVariables = { fontFamily: directive.fontFamily };
-    } else {
-      if (!directive.themeVariables.fontFamily) {
-        directive.themeVariables = { fontFamily: directive.fontFamily };
-      }
-    }
+export const addDirective = (directive: MermaidConfig) => {
+  sanitizeDirective(directive);
+
+  // If the directive has a fontFamily, but no themeVariables, add the fontFamily to the themeVariables
+  if (directive.fontFamily && (!directive.themeVariables || !directive.themeVariables.fontFamily)) {
+    directive.themeVariables = { fontFamily: directive.fontFamily };
   }
+
   directives.push(directive);
   updateCurrentConfig(siteConfig, directives);
 };
diff --git a/packages/mermaid/src/directiveUtils.ts b/packages/mermaid/src/directiveUtils.ts
index 563856631..baf628e74 100644
--- a/packages/mermaid/src/directiveUtils.ts
+++ b/packages/mermaid/src/directiveUtils.ts
@@ -1,7 +1,5 @@
 import * as configApi from './config.js';
-
 import { log } from './logger.js';
-import { directiveSanitizer } from './utils.js';
 
 let currentDirective: { type?: string; args?: any } | undefined = {};
 
@@ -60,9 +58,6 @@ const handleDirective = function (p: any, directive: any, type: string): void {
           delete directive.args[prop];
         }
       });
-      log.info('sanitize in handleDirective', directive.args);
-      directiveSanitizer(directive.args);
-      log.info('sanitize in handleDirective (done)', directive.args);
       configApi.addDirective(directive.args);
       break;
     }
diff --git a/packages/mermaid/src/mermaidAPI.ts b/packages/mermaid/src/mermaidAPI.ts
index f8a36f88e..35b251bc7 100644
--- a/packages/mermaid/src/mermaidAPI.ts
+++ b/packages/mermaid/src/mermaidAPI.ts
@@ -23,7 +23,7 @@ import { attachFunctions } from './interactionDb.js';
 import { log, setLogLevel } from './logger.js';
 import getStyles from './styles.js';
 import theme from './themes/index.js';
-import utils, { directiveSanitizer } from './utils.js';
+import utils from './utils.js';
 import DOMPurify from 'dompurify';
 import { MermaidConfig } from './config.type.js';
 import { evaluate } from './diagrams/common/common.js';
@@ -388,7 +388,6 @@ const render = async function (
   // Add Directives. Must do this before getting the config and before creating the diagram.
   const graphInit = utils.detectInit(text);
   if (graphInit) {
-    directiveSanitizer(graphInit);
     configApi.addDirective(graphInit);
   }
 
diff --git a/packages/mermaid/src/utils.ts b/packages/mermaid/src/utils.ts
index f054ef29f..dd574f86a 100644
--- a/packages/mermaid/src/utils.ts
+++ b/packages/mermaid/src/utils.ts
@@ -102,8 +102,6 @@ export const detectInit = function (text: string, config?: MermaidConfig): Merma
 
   if (Array.isArray(inits)) {
     const args = inits.map((init) => init.args);
-    sanitizeDirective(args);
-
     results = assignWithDepth(results, [...args]);
   } else {
     results = inits.args;

From 767baa4ec6bd5d478df500b1c77b0e68a1e21794 Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Mon, 21 Aug 2023 10:18:23 +0530
Subject: [PATCH 15/70] chore: Fix type in assignWithDepth

---
 packages/mermaid/src/assignWithDepth.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/mermaid/src/assignWithDepth.ts b/packages/mermaid/src/assignWithDepth.ts
index 831825779..125b6f434 100644
--- a/packages/mermaid/src/assignWithDepth.ts
+++ b/packages/mermaid/src/assignWithDepth.ts
@@ -1,7 +1,7 @@
 /* eslint-disable @typescript-eslint/no-explicit-any */
 
 /**
- * assignWithDepth Extends the functionality of {@link ObjectConstructor.assign} with the
+ * assignWithDepth Extends the functionality of {@link Object.assign} with the
  *   ability to merge arbitrary-depth objects For each key in src with path `k` (recursively)
  *   performs an Object.assign(dst[`k`], src[`k`]) with a slight change from the typical handling of
  *   undefined for dst[`k`]: instead of raising an error, dst[`k`] is auto-initialized to `{}` and

From 31c0a0cbab3d59f3e92b16a475e95a22e278550f Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Mon, 21 Aug 2023 10:26:41 +0530
Subject: [PATCH 16/70] deps: Update unocss and webpack to address
 vulnerability.

---
 packages/mermaid/src/docs/package.json |   4 +-
 pnpm-lock.yaml                         | 533 ++++++++++++-------------
 tests/webpack/package.json             |   2 +-
 3 files changed, 257 insertions(+), 282 deletions(-)

diff --git a/packages/mermaid/src/docs/package.json b/packages/mermaid/src/docs/package.json
index defc98082..a5cb5859c 100644
--- a/packages/mermaid/src/docs/package.json
+++ b/packages/mermaid/src/docs/package.json
@@ -21,13 +21,13 @@
   },
   "devDependencies": {
     "@iconify-json/carbon": "^1.1.16",
-    "@unocss/reset": "^0.55.0",
+    "@unocss/reset": "^0.55.2",
     "@vite-pwa/vitepress": "^0.2.0",
     "@vitejs/plugin-vue": "^4.2.1",
     "fast-glob": "^3.2.12",
     "https-localhost": "^4.7.1",
     "pathe": "^1.1.0",
-    "unocss": "^0.55.0",
+    "unocss": "^0.55.2",
     "unplugin-vue-components": "^0.25.0",
     "vite": "^4.3.9",
     "vite-plugin-pwa": "^0.16.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d30b49a73..8dc7ec846 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -22,7 +22,7 @@ importers:
         version: 6.31.1
       '@cypress/code-coverage':
         specifier: ^3.10.7
-        version: 3.10.7(@babel/core@7.12.3)(@babel/preset-env@7.20.2)(babel-loader@9.1.2)(cypress@12.10.0)(webpack@5.75.0)
+        version: 3.10.7(@babel/core@7.12.3)(@babel/preset-env@7.20.2)(babel-loader@9.1.2)(cypress@12.10.0)(webpack@5.88.2)
       '@rollup/plugin-typescript':
         specifier: ^11.1.1
         version: 11.1.1(typescript@5.1.3)
@@ -442,8 +442,8 @@ importers:
         specifier: ^1.1.16
         version: 1.1.16
       '@unocss/reset':
-        specifier: ^0.55.0
-        version: 0.55.0
+        specifier: ^0.55.2
+        version: 0.55.2
       '@vite-pwa/vitepress':
         specifier: ^0.2.0
         version: 0.2.0(vite-plugin-pwa@0.16.0)
@@ -460,8 +460,8 @@ importers:
         specifier: ^1.1.0
         version: 1.1.0
       unocss:
-        specifier: ^0.55.0
-        version: 0.55.0(postcss@8.4.27)(rollup@2.79.1)(vite@4.3.9)
+        specifier: ^0.55.2
+        version: 0.55.2(postcss@8.4.27)(rollup@2.79.1)(vite@4.3.9)
       unplugin-vue-components:
         specifier: ^0.25.0
         version: 0.25.0(rollup@2.79.1)(vue@3.3.4)
@@ -494,8 +494,8 @@ importers:
         specifier: ^1.1.16
         version: 1.1.16
       '@unocss/reset':
-        specifier: ^0.55.0
-        version: 0.55.0
+        specifier: ^0.55.2
+        version: 0.55.2
       '@vite-pwa/vitepress':
         specifier: ^0.2.0
         version: 0.2.0(vite-plugin-pwa@0.16.0)
@@ -512,8 +512,8 @@ importers:
         specifier: ^1.1.0
         version: 1.1.0
       unocss:
-        specifier: ^0.55.0
-        version: 0.55.0(postcss@8.4.27)(rollup@2.79.1)(vite@4.3.9)
+        specifier: ^0.55.2
+        version: 0.55.2(postcss@8.4.27)(rollup@2.79.1)(vite@4.3.9)
       unplugin-vue-components:
         specifier: ^0.25.0
         version: 0.25.0(rollup@2.79.1)(vue@3.3.4)
@@ -540,14 +540,14 @@ importers:
         version: link:../../packages/mermaid
     devDependencies:
       webpack:
-        specifier: ^5.74.0
-        version: 5.75.0(esbuild@0.19.0)(webpack-cli@4.10.0)
+        specifier: ^5.88.2
+        version: 5.88.2(esbuild@0.19.0)(webpack-cli@4.10.0)
       webpack-cli:
         specifier: ^4.10.0
-        version: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.75.0)
+        version: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.88.2)
       webpack-dev-server:
         specifier: ^4.11.1
-        version: 4.11.1(webpack-cli@4.10.0)(webpack@5.75.0)
+        version: 4.11.1(webpack-cli@4.10.0)(webpack@5.88.2)
 
 packages:
 
@@ -2788,12 +2788,12 @@ packages:
     dependencies:
       '@jridgewell/trace-mapping': 0.3.9
 
-  /@cypress/code-coverage@3.10.7(@babel/core@7.12.3)(@babel/preset-env@7.20.2)(babel-loader@9.1.2)(cypress@12.10.0)(webpack@5.75.0):
+  /@cypress/code-coverage@3.10.7(@babel/core@7.12.3)(@babel/preset-env@7.20.2)(babel-loader@9.1.2)(cypress@12.10.0)(webpack@5.88.2):
     resolution: {integrity: sha512-kQFB8GemDAAk6JBINsR9MLEgCw2AKb3FcdHQjIJ3KV4ZER6ZF0NGdO8SRj5oTVp28oqfOab4cgoBdecRiOE3qA==}
     peerDependencies:
       cypress: '*'
     dependencies:
-      '@cypress/webpack-preprocessor': 5.17.1(@babel/core@7.12.3)(@babel/preset-env@7.20.2)(babel-loader@9.1.2)(webpack@5.75.0)
+      '@cypress/webpack-preprocessor': 5.17.1(@babel/core@7.12.3)(@babel/preset-env@7.20.2)(babel-loader@9.1.2)(webpack@5.88.2)
       chalk: 4.1.2
       cypress: 12.10.0
       dayjs: 1.10.7
@@ -2835,7 +2835,7 @@ packages:
       uuid: 8.3.2
     dev: true
 
-  /@cypress/webpack-preprocessor@5.17.1(@babel/core@7.12.3)(@babel/preset-env@7.20.2)(babel-loader@9.1.2)(webpack@5.75.0):
+  /@cypress/webpack-preprocessor@5.17.1(@babel/core@7.12.3)(@babel/preset-env@7.20.2)(babel-loader@9.1.2)(webpack@5.88.2):
     resolution: {integrity: sha512-FE/e8ikPc8z4EVopJCaior3RGy0jd2q9Xcp5NtiwNG4XnLfEnUFTZlAGwXe75sEh4fNMPrBJW1KIz77PX5vGAw==}
     peerDependencies:
       '@babel/core': ^7.0.1
@@ -2845,11 +2845,11 @@ packages:
     dependencies:
       '@babel/core': 7.12.3
       '@babel/preset-env': 7.20.2(@babel/core@7.12.3)
-      babel-loader: 9.1.2(@babel/core@7.12.3)(webpack@5.75.0)
+      babel-loader: 9.1.2(@babel/core@7.12.3)(webpack@5.88.2)
       bluebird: 3.7.1
       debug: 4.3.4(supports-color@8.1.1)
       lodash: 4.17.21
-      webpack: 5.75.0(esbuild@0.19.0)(webpack-cli@4.10.0)
+      webpack: 5.88.2(esbuild@0.19.0)(webpack-cli@4.10.0)
     transitivePeerDependencies:
       - supports-color
     dev: true
@@ -3898,8 +3898,8 @@ packages:
     resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==}
     engines: {node: '>=6.0.0'}
 
-  /@jridgewell/source-map@0.3.2:
-    resolution: {integrity: sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==}
+  /@jridgewell/source-map@0.3.5:
+    resolution: {integrity: sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==}
     dependencies:
       '@jridgewell/gen-mapping': 0.3.2
       '@jridgewell/trace-mapping': 0.3.17
@@ -4076,6 +4076,21 @@ packages:
       rollup: 2.79.1
     dev: true
 
+  /@rollup/pluginutils@5.0.3(rollup@2.79.1):
+    resolution: {integrity: sha512-hfllNN4a80rwNQ9QCxhxuHCGHMAvabXqxNdaChUSSadMre7t4iEUI6fFAhBOn/eIYTgYVhBv7vCLsAJ4u3lf3g==}
+    engines: {node: '>=14.0.0'}
+    peerDependencies:
+      rollup: ^1.20.0||^2.0.0||^3.0.0
+    peerDependenciesMeta:
+      rollup:
+        optional: true
+    dependencies:
+      '@types/estree': 1.0.0
+      estree-walker: 2.0.2
+      picomatch: 2.3.1
+      rollup: 2.79.1
+    dev: true
+
   /@sideway/address@4.1.4:
     resolution: {integrity: sha512-7vwq+rOHVWjyXxVlR76Agnvhy8I9rpzjosTESvmhNeXOXdZZB15Fl+TI9x1SiHZH5Jv2wTGduSxFDIaq0m3DUw==}
     dependencies:
@@ -4457,10 +4472,6 @@ packages:
     resolution: {integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==}
     dev: true
 
-  /@types/estree@0.0.51:
-    resolution: {integrity: sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==}
-    dev: true
-
   /@types/estree@1.0.0:
     resolution: {integrity: sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==}
     dev: true
@@ -5008,32 +5019,32 @@ packages:
       eslint-visitor-keys: 3.4.0
     dev: true
 
-  /@unocss/astro@0.55.0(rollup@2.79.1)(vite@4.3.9):
-    resolution: {integrity: sha512-Qqk8zONPBBigEcUOGhEwBPIQmWnQGpjpQrSdpjs86BphKbQcqWHES1fQA83Fk2tpZ08zo0zAPDJ8VhfR+c+yqg==}
+  /@unocss/astro@0.55.2(rollup@2.79.1)(vite@4.3.9):
+    resolution: {integrity: sha512-cSzBKPEveZZQDZp5bq0UlL8CVvzB/1LsgZmZufxi9oMMjMJYqzfTkKg5z65GcP82Xp5c0N3KKkl/R6I+/7Iwvw==}
     peerDependencies:
       vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0
     peerDependenciesMeta:
       vite:
         optional: true
     dependencies:
-      '@unocss/core': 0.55.0
-      '@unocss/reset': 0.55.0
-      '@unocss/vite': 0.55.0(rollup@2.79.1)(vite@4.3.9)
+      '@unocss/core': 0.55.2
+      '@unocss/reset': 0.55.2
+      '@unocss/vite': 0.55.2(rollup@2.79.1)(vite@4.3.9)
       vite: 4.3.9(@types/node@18.16.0)
     transitivePeerDependencies:
       - rollup
     dev: true
 
-  /@unocss/cli@0.55.0(rollup@2.79.1):
-    resolution: {integrity: sha512-K8PR4UydtTfT8rMynDcNQKk1WWI97312kZYjBLHUlrJkNbSgcmpU3wfREIqvCSgPg61ttZAgE5uI6omf8FudtA==}
+  /@unocss/cli@0.55.2(rollup@2.79.1):
+    resolution: {integrity: sha512-ZJ8aBhm+3WjGCA5HcOQ4C3mbtJwkgMX2gpjjJ0MPh/iZOz3+/zmHlrXJCS3jIFouRYSwxxanWdrGUuLIQLqPhQ==}
     engines: {node: '>=14'}
     hasBin: true
     dependencies:
       '@ampproject/remapping': 2.2.1
-      '@rollup/pluginutils': 5.0.2(rollup@2.79.1)
-      '@unocss/config': 0.55.0
-      '@unocss/core': 0.55.0
-      '@unocss/preset-uno': 0.55.0
+      '@rollup/pluginutils': 5.0.3(rollup@2.79.1)
+      '@unocss/config': 0.55.2
+      '@unocss/core': 0.55.2
+      '@unocss/preset-uno': 0.55.2
       cac: 6.7.14
       chokidar: 3.5.3
       colorette: 2.0.20
@@ -5046,154 +5057,154 @@ packages:
       - rollup
     dev: true
 
-  /@unocss/config@0.55.0:
-    resolution: {integrity: sha512-N1o49aqqMP8UTmFZKsqN+CZFxoiUbatTYdPixCGErI5H6jA0VByVU7RI3Dr+Lk3PTOxbmZUunaDaWZP3iT4X5w==}
+  /@unocss/config@0.55.2:
+    resolution: {integrity: sha512-RYDv9QzhUeBz9BY+Pty0xc9vk/m4LGBNMiBghcItW6zXN554JbSuoPD55DmnvO2iXrIYujBZdB/Kob6GLCZpqw==}
     engines: {node: '>=14'}
     dependencies:
-      '@unocss/core': 0.55.0
+      '@unocss/core': 0.55.2
       unconfig: 0.3.10
     dev: true
 
-  /@unocss/core@0.55.0:
-    resolution: {integrity: sha512-TcTugpuhsv6OwMsP3iFIG8FVc9N5JzkojIGNAKF8I2WBftZ//3QcpEHiHc1mH3MlPYfJgUvCcT6/Gad55qmHzg==}
+  /@unocss/core@0.55.2:
+    resolution: {integrity: sha512-ZLEES8RDgWoK/vttUzl3PM2bZqL3HvhLgj8xdDa09Xw+JiTlR4c66s+hLn52oCoJTnT9lGsD2j7tTGN9ToSiTA==}
     dev: true
 
-  /@unocss/extractor-arbitrary-variants@0.55.0:
-    resolution: {integrity: sha512-FCel+gJ3N8C/361yQ3gYTmbCjX3DXQ+LdxBiAawapbtTA4eXw55/f7cpiiWcHoouCRrWIEMOQN5DskAJvmMaTw==}
+  /@unocss/extractor-arbitrary-variants@0.55.2:
+    resolution: {integrity: sha512-mHEoFx+ITe3OgFoIUhkCQxRgUjvOJeHtI1Z3Sm8NDMy2vTqOlkSf7NLWEyFfQsSFYqpWGTkaW1XiMZujGMoB/g==}
     dependencies:
-      '@unocss/core': 0.55.0
+      '@unocss/core': 0.55.2
     dev: true
 
-  /@unocss/inspector@0.55.0:
-    resolution: {integrity: sha512-wIkypLsBUA76A9cpyf/VtbVU7TLJO9HETEVMZytxEyVpq4KVNJBwNLUGWQ07IOc0oRTX+HJKiQK9/bLnIYMCHA==}
+  /@unocss/inspector@0.55.2:
+    resolution: {integrity: sha512-AMNZ7FsBFhQCMuAQugCk7d+3uoHDN2VFwCzSxk0ITgG51J90jfVgAo9mJf28W/AM4g0qVHScveJDPKzA+2o+Vg==}
     dependencies:
       gzip-size: 6.0.0
       sirv: 2.0.3
     dev: true
 
-  /@unocss/postcss@0.55.0(postcss@8.4.27):
-    resolution: {integrity: sha512-qytqO8riNLpy1m6qVfISVHw3dwNRHgpxcUaufSN7P8lgsbOimwh2nRE35f/HoKS1VV+5JVsVaHmUFQVxwiW6cw==}
+  /@unocss/postcss@0.55.2(postcss@8.4.27):
+    resolution: {integrity: sha512-HJLGINNlQ3DGL9zRGuctX+mOVW2w7o8Wj89v3/2qTcqXBDpwfn1+KlxSjU9rsEPdE4Ur3MIcVXcJC0wz4+EwEA==}
     engines: {node: '>=14'}
     peerDependencies:
       postcss: ^8.4.21
     dependencies:
-      '@unocss/config': 0.55.0
-      '@unocss/core': 0.55.0
+      '@unocss/config': 0.55.2
+      '@unocss/core': 0.55.2
       css-tree: 2.3.1
       fast-glob: 3.3.1
       magic-string: 0.30.2
       postcss: 8.4.27
     dev: true
 
-  /@unocss/preset-attributify@0.55.0:
-    resolution: {integrity: sha512-AbqoamJLsFqJih1MMyxEslLScWSpOdlTbF9R+gSnrWwkGZDuZszcyTDbXrhCPWPUkihR7NY9XQSKxUkTb6MJJg==}
+  /@unocss/preset-attributify@0.55.2:
+    resolution: {integrity: sha512-jn5ulsKpAipsX3Gf2/iSZydgI0eP1ENeoS6rrNBL8zl1mRihnZYFegS75rGYjO6sEfEHrhkBiSHOw7Uv5KtLbw==}
     dependencies:
-      '@unocss/core': 0.55.0
+      '@unocss/core': 0.55.2
     dev: true
 
-  /@unocss/preset-icons@0.55.0:
-    resolution: {integrity: sha512-BeseXUz2WFRztLtfblGhpFBJkgKi8k7tKPyEx/QX2I/xhQNsXqfWqeiCEVLxrEI3HxXOZPV1G4idCCbBiZQ3ww==}
+  /@unocss/preset-icons@0.55.2:
+    resolution: {integrity: sha512-NK9LcTlBZv6zO8Qbu+VA9HblzYc5ebuFwaQMfQcYj2Z6dBOT27Ki41LY1qjEXzzMPXb44Q14Rlk0tJc8LtJIpQ==}
     dependencies:
       '@iconify/utils': 2.1.7
-      '@unocss/core': 0.55.0
+      '@unocss/core': 0.55.2
       ofetch: 1.1.1
     transitivePeerDependencies:
       - supports-color
     dev: true
 
-  /@unocss/preset-mini@0.55.0:
-    resolution: {integrity: sha512-zAMLmpCBXE36CDCrMtvxNp7lN9mk5QpArPpLekR3lPZ7NTAYSxHkieCJ0TryeOYWlt1sBdrOFE8X0cQCyG96Zg==}
+  /@unocss/preset-mini@0.55.2:
+    resolution: {integrity: sha512-jwUsrwtPwMvFVJUP+FVFjq+sp+xQPyFLRPSb89ZI34F1a3EwJ2wioDICLqWjOjY7zei9UgtSY0owBM9vwxw/kg==}
     dependencies:
-      '@unocss/core': 0.55.0
-      '@unocss/extractor-arbitrary-variants': 0.55.0
+      '@unocss/core': 0.55.2
+      '@unocss/extractor-arbitrary-variants': 0.55.2
     dev: true
 
-  /@unocss/preset-tagify@0.55.0:
-    resolution: {integrity: sha512-crvJAZpG2ge9Lq51vpWANiB3BKv8Vs8sjplwRfUVRCYMiN7ZNzq9bNzUwTXhJXmRJ4LVjTSFciKPQR7fCjUScA==}
+  /@unocss/preset-tagify@0.55.2:
+    resolution: {integrity: sha512-m8/9wBtUQSwnwsLANhUOc7sukF8ReHJ7ZC6fCfTozRMOhwu+bDcf9G7pguXdNC4DdZXI15cvbZzkYF2l733qUw==}
     dependencies:
-      '@unocss/core': 0.55.0
+      '@unocss/core': 0.55.2
     dev: true
 
-  /@unocss/preset-typography@0.55.0:
-    resolution: {integrity: sha512-M4fJUEzkBqjxEUIDbwoWb00hjPbpwZKDOcB81S0F+xE3SVu1pQj8KgymhxaJvz+FxGZRajnJJ9esaGPIrzG2gQ==}
+  /@unocss/preset-typography@0.55.2:
+    resolution: {integrity: sha512-Y4JEihpKPDlXWXxnnMZbQclqZ4+DUD8RVFk46ERe9CLNEYkFObd4LG7yfSurr/C01zuU/GhEMyOWqSGsSyCxKg==}
     dependencies:
-      '@unocss/core': 0.55.0
-      '@unocss/preset-mini': 0.55.0
+      '@unocss/core': 0.55.2
+      '@unocss/preset-mini': 0.55.2
     dev: true
 
-  /@unocss/preset-uno@0.55.0:
-    resolution: {integrity: sha512-iYGdE/MQLAvpQkyQ8f3aolC9NK9NtrG87LfQmiKu/RpzjghDlTY8VTuWIDcdIk80zTtOxRtitLqGEsoDl8WnuA==}
+  /@unocss/preset-uno@0.55.2:
+    resolution: {integrity: sha512-8VJXC6+f5YBjUaTkf+EGAembDYMleb0zjkb4hwXxjPIsO+mXixdZC2icCiN/12DLlwH4FzEvObLKns3CGEAZZw==}
     dependencies:
-      '@unocss/core': 0.55.0
-      '@unocss/preset-mini': 0.55.0
-      '@unocss/preset-wind': 0.55.0
+      '@unocss/core': 0.55.2
+      '@unocss/preset-mini': 0.55.2
+      '@unocss/preset-wind': 0.55.2
     dev: true
 
-  /@unocss/preset-web-fonts@0.55.0:
-    resolution: {integrity: sha512-nFA5q0WinD/z7Iqv3uJQ8sTK7mQf18qbcFKmgWZ+QZXdI/wACOfExd6futsXj5EdACJwsEixYJe4DURTsD5XtA==}
+  /@unocss/preset-web-fonts@0.55.2:
+    resolution: {integrity: sha512-kRnrfZPDkU2r9tp507rsh4kwhUzZ76XBTZLmElYm8tlP6HZzIHcFF8fdW15J4nh81b/IGw8ZOS7aQmqtHu3A8A==}
     dependencies:
-      '@unocss/core': 0.55.0
+      '@unocss/core': 0.55.2
       ofetch: 1.1.1
     dev: true
 
-  /@unocss/preset-wind@0.55.0:
-    resolution: {integrity: sha512-H9vNXdEJVQx1UO367V3RInAUj4qrsPCXm914RNC4D7qojOuPQlipW0YD5WFklcXeI/k0f1B30VjDYGZhV0jykg==}
+  /@unocss/preset-wind@0.55.2:
+    resolution: {integrity: sha512-th/aOokb10ApaiVLNI093mvko4XryJ70oEhzz4tHdSuhnQWf5eY7+k7y9EEYFz8i1OOrKuer0HzUV27llZaufw==}
     dependencies:
-      '@unocss/core': 0.55.0
-      '@unocss/preset-mini': 0.55.0
+      '@unocss/core': 0.55.2
+      '@unocss/preset-mini': 0.55.2
     dev: true
 
-  /@unocss/reset@0.55.0:
-    resolution: {integrity: sha512-TzpcOCIr16IbFxQ4vrSfEV+A8k0N4mJkhl7J3SZfAxBpNDBKAWDB6VBW9iEQY5aBYDLN3wRx1LskgEoubqBCPQ==}
+  /@unocss/reset@0.55.2:
+    resolution: {integrity: sha512-paInTGIhtI96fcJGZWbkPLW/7qiTlHxSbEIs1HGHcbf3WbwNuKrJUvKlQAhUs2HILNKhvsTXQl05Os8gtinLEA==}
     dev: true
 
-  /@unocss/scope@0.55.0:
-    resolution: {integrity: sha512-44xgHoklh2BWWuOkA0ZL1qgr4t/DGnynj3UI8K8YP+PClFFMZ/T+kfhsLBDOrS2a4ytzgh17cTGhjAc3cTwiEA==}
+  /@unocss/scope@0.55.2:
+    resolution: {integrity: sha512-o1b86ejgaFDqfC712mUZqZDQNf6o1xDzm6+bgHySdiltR8Quo6l8RcoZjZrCvEogtPbko4/XJ374t1NQMUQf4g==}
     dev: true
 
-  /@unocss/transformer-attributify-jsx-babel@0.55.0:
-    resolution: {integrity: sha512-gsPuD56gNw47AFgOmdpqT9+gdisLXKnPccF4ozZoqGOv3Hy2MPOc+Dkwk7qkDzzSdC39G5Aq09z8X9R2vU64XQ==}
+  /@unocss/transformer-attributify-jsx-babel@0.55.2:
+    resolution: {integrity: sha512-pmfF546i8pKfMNeYZOJz2UzbuUwj0v7GqcoP5fClyRUzBMUfXdJwBSdFaYkdWR5Q/O1sv+pI0S8r/G9T7QuldA==}
     dependencies:
-      '@unocss/core': 0.55.0
+      '@unocss/core': 0.55.2
     dev: true
 
-  /@unocss/transformer-attributify-jsx@0.55.0:
-    resolution: {integrity: sha512-17/4I2Uqj44JJ4iv3e/mBH1DsWvyVbbbA9JivS/iBPferdFTPtt4Buddhm7bkx1tE86KYZcokVZ8N5RA2zu2UQ==}
+  /@unocss/transformer-attributify-jsx@0.55.2:
+    resolution: {integrity: sha512-WerdaNagorTtYDvbhlZEmeuBrQ5lmPE0vG9r20bPR/vLy9UmbIFPpzt6b/hSLqOUnZnaEfbrpNUlpBZgUXpvsg==}
     dependencies:
-      '@unocss/core': 0.55.0
+      '@unocss/core': 0.55.2
     dev: true
 
-  /@unocss/transformer-compile-class@0.55.0:
-    resolution: {integrity: sha512-aH2SWXqOGJAEuNS1S/fIfs0gFwnakxgG83PCS40uNbEiLv/iG0HuALaQbVvyWHo3O7xLoMa7os9p72Q2amaVQw==}
+  /@unocss/transformer-compile-class@0.55.2:
+    resolution: {integrity: sha512-zKeJtAirFrgj8TheKplgdKrPV9hPN3i2gEy/aQ+CrHHImcQtxZ1FJzmJT1yV77MOXOdeRJOhiePNOe2TE1A4tw==}
     dependencies:
-      '@unocss/core': 0.55.0
+      '@unocss/core': 0.55.2
     dev: true
 
-  /@unocss/transformer-directives@0.55.0:
-    resolution: {integrity: sha512-bWfAOqQxzy5vIul/jgXN2b0APAk9tWKeTN9Rh4FWvz+dI0P7cBc3rHVEC5qM3i9xwYObtjQcNZjEfJpyeapnzg==}
+  /@unocss/transformer-directives@0.55.2:
+    resolution: {integrity: sha512-IJKL5clOiv2RjvHYr4xumS4eFScPsi3Vg4vGugsmn43PZ1FsApp8UElHfhuhBsEEiffnsgTD+N5u/EiPpyI0Gw==}
     dependencies:
-      '@unocss/core': 0.55.0
+      '@unocss/core': 0.55.2
       css-tree: 2.3.1
     dev: true
 
-  /@unocss/transformer-variant-group@0.55.0:
-    resolution: {integrity: sha512-0VSvQpEmN8/Y+CfVMhL1+u1+FjmDFtviqKz8aaLFBapC/hnxbkAQTZRVv7mFNvBhBVUHXZOz7LASR4q9RtIeVA==}
+  /@unocss/transformer-variant-group@0.55.2:
+    resolution: {integrity: sha512-BIAigftn+mfUeQT7sPzJNgvvbrmLj0gmYmeK4U7/8NxUuOuC0ROTNSw+MKU7yDiPYHqb1kxVZ47LZ3GdUcNPRA==}
     dependencies:
-      '@unocss/core': 0.55.0
+      '@unocss/core': 0.55.2
     dev: true
 
-  /@unocss/vite@0.55.0(rollup@2.79.1)(vite@4.3.9):
-    resolution: {integrity: sha512-qUOqJzSnztCQFXOCNOCqpwwziVMmygXmdbuaqNAmkAg2EzoMSacQKzmLIj49UU0l+iykf2mDh8DmQxpnEU2JSQ==}
+  /@unocss/vite@0.55.2(rollup@2.79.1)(vite@4.3.9):
+    resolution: {integrity: sha512-JEyEaJt8D+Ed3Z8GDQ0hMWqKsB47/DoS+aPzDoXSIVozgi8seHtfSChBOBUSgcCrozfBVp42YHbYYyloDkb2Yw==}
     peerDependencies:
       vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0
     dependencies:
       '@ampproject/remapping': 2.2.1
-      '@rollup/pluginutils': 5.0.2(rollup@2.79.1)
-      '@unocss/config': 0.55.0
-      '@unocss/core': 0.55.0
-      '@unocss/inspector': 0.55.0
-      '@unocss/scope': 0.55.0
-      '@unocss/transformer-directives': 0.55.0
+      '@rollup/pluginutils': 5.0.3(rollup@2.79.1)
+      '@unocss/config': 0.55.2
+      '@unocss/core': 0.55.2
+      '@unocss/inspector': 0.55.2
+      '@unocss/scope': 0.55.2
+      '@unocss/transformer-directives': 0.55.2
       chokidar: 3.5.3
       fast-glob: 3.3.1
       magic-string: 0.30.2
@@ -5546,120 +5557,120 @@ packages:
       - typescript
     dev: true
 
-  /@webassemblyjs/ast@1.11.1:
-    resolution: {integrity: sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw==}
+  /@webassemblyjs/ast@1.11.6:
+    resolution: {integrity: sha512-IN1xI7PwOvLPgjcf180gC1bqn3q/QaOCwYUahIOhbYUu8KA/3tw2RT/T0Gidi1l7Hhj5D/INhJxiICObqpMu4Q==}
     dependencies:
-      '@webassemblyjs/helper-numbers': 1.11.1
-      '@webassemblyjs/helper-wasm-bytecode': 1.11.1
+      '@webassemblyjs/helper-numbers': 1.11.6
+      '@webassemblyjs/helper-wasm-bytecode': 1.11.6
     dev: true
 
-  /@webassemblyjs/floating-point-hex-parser@1.11.1:
-    resolution: {integrity: sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ==}
+  /@webassemblyjs/floating-point-hex-parser@1.11.6:
+    resolution: {integrity: sha512-ejAj9hfRJ2XMsNHk/v6Fu2dGS+i4UaXBXGemOfQ/JfQ6mdQg/WXtwleQRLLS4OvfDhv8rYnVwH27YJLMyYsxhw==}
     dev: true
 
-  /@webassemblyjs/helper-api-error@1.11.1:
-    resolution: {integrity: sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg==}
+  /@webassemblyjs/helper-api-error@1.11.6:
+    resolution: {integrity: sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q==}
     dev: true
 
-  /@webassemblyjs/helper-buffer@1.11.1:
-    resolution: {integrity: sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA==}
+  /@webassemblyjs/helper-buffer@1.11.6:
+    resolution: {integrity: sha512-z3nFzdcp1mb8nEOFFk8DrYLpHvhKC3grJD2ardfKOzmbmJvEf/tPIqCY+sNcwZIY8ZD7IkB2l7/pqhUhqm7hLA==}
     dev: true
 
-  /@webassemblyjs/helper-numbers@1.11.1:
-    resolution: {integrity: sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ==}
+  /@webassemblyjs/helper-numbers@1.11.6:
+    resolution: {integrity: sha512-vUIhZ8LZoIWHBohiEObxVm6hwP034jwmc9kuq5GdHZH0wiLVLIPcMCdpJzG4C11cHoQ25TFIQj9kaVADVX7N3g==}
     dependencies:
-      '@webassemblyjs/floating-point-hex-parser': 1.11.1
-      '@webassemblyjs/helper-api-error': 1.11.1
+      '@webassemblyjs/floating-point-hex-parser': 1.11.6
+      '@webassemblyjs/helper-api-error': 1.11.6
       '@xtuc/long': 4.2.2
     dev: true
 
-  /@webassemblyjs/helper-wasm-bytecode@1.11.1:
-    resolution: {integrity: sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q==}
+  /@webassemblyjs/helper-wasm-bytecode@1.11.6:
+    resolution: {integrity: sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA==}
     dev: true
 
-  /@webassemblyjs/helper-wasm-section@1.11.1:
-    resolution: {integrity: sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg==}
+  /@webassemblyjs/helper-wasm-section@1.11.6:
+    resolution: {integrity: sha512-LPpZbSOwTpEC2cgn4hTydySy1Ke+XEu+ETXuoyvuyezHO3Kjdu90KK95Sh9xTbmjrCsUwvWwCOQQNta37VrS9g==}
     dependencies:
-      '@webassemblyjs/ast': 1.11.1
-      '@webassemblyjs/helper-buffer': 1.11.1
-      '@webassemblyjs/helper-wasm-bytecode': 1.11.1
-      '@webassemblyjs/wasm-gen': 1.11.1
+      '@webassemblyjs/ast': 1.11.6
+      '@webassemblyjs/helper-buffer': 1.11.6
+      '@webassemblyjs/helper-wasm-bytecode': 1.11.6
+      '@webassemblyjs/wasm-gen': 1.11.6
     dev: true
 
-  /@webassemblyjs/ieee754@1.11.1:
-    resolution: {integrity: sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ==}
+  /@webassemblyjs/ieee754@1.11.6:
+    resolution: {integrity: sha512-LM4p2csPNvbij6U1f19v6WR56QZ8JcHg3QIJTlSwzFcmx6WSORicYj6I63f9yU1kEUtrpG+kjkiIAkevHpDXrg==}
     dependencies:
       '@xtuc/ieee754': 1.2.0
     dev: true
 
-  /@webassemblyjs/leb128@1.11.1:
-    resolution: {integrity: sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw==}
+  /@webassemblyjs/leb128@1.11.6:
+    resolution: {integrity: sha512-m7a0FhE67DQXgouf1tbN5XQcdWoNgaAuoULHIfGFIEVKA6tu/edls6XnIlkmS6FrXAquJRPni3ZZKjw6FSPjPQ==}
     dependencies:
       '@xtuc/long': 4.2.2
     dev: true
 
-  /@webassemblyjs/utf8@1.11.1:
-    resolution: {integrity: sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ==}
+  /@webassemblyjs/utf8@1.11.6:
+    resolution: {integrity: sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA==}
     dev: true
 
-  /@webassemblyjs/wasm-edit@1.11.1:
-    resolution: {integrity: sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA==}
+  /@webassemblyjs/wasm-edit@1.11.6:
+    resolution: {integrity: sha512-Ybn2I6fnfIGuCR+Faaz7YcvtBKxvoLV3Lebn1tM4o/IAJzmi9AWYIPWpyBfU8cC+JxAO57bk4+zdsTjJR+VTOw==}
     dependencies:
-      '@webassemblyjs/ast': 1.11.1
-      '@webassemblyjs/helper-buffer': 1.11.1
-      '@webassemblyjs/helper-wasm-bytecode': 1.11.1
-      '@webassemblyjs/helper-wasm-section': 1.11.1
-      '@webassemblyjs/wasm-gen': 1.11.1
-      '@webassemblyjs/wasm-opt': 1.11.1
-      '@webassemblyjs/wasm-parser': 1.11.1
-      '@webassemblyjs/wast-printer': 1.11.1
+      '@webassemblyjs/ast': 1.11.6
+      '@webassemblyjs/helper-buffer': 1.11.6
+      '@webassemblyjs/helper-wasm-bytecode': 1.11.6
+      '@webassemblyjs/helper-wasm-section': 1.11.6
+      '@webassemblyjs/wasm-gen': 1.11.6
+      '@webassemblyjs/wasm-opt': 1.11.6
+      '@webassemblyjs/wasm-parser': 1.11.6
+      '@webassemblyjs/wast-printer': 1.11.6
     dev: true
 
-  /@webassemblyjs/wasm-gen@1.11.1:
-    resolution: {integrity: sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA==}
+  /@webassemblyjs/wasm-gen@1.11.6:
+    resolution: {integrity: sha512-3XOqkZP/y6B4F0PBAXvI1/bky7GryoogUtfwExeP/v7Nzwo1QLcq5oQmpKlftZLbT+ERUOAZVQjuNVak6UXjPA==}
     dependencies:
-      '@webassemblyjs/ast': 1.11.1
-      '@webassemblyjs/helper-wasm-bytecode': 1.11.1
-      '@webassemblyjs/ieee754': 1.11.1
-      '@webassemblyjs/leb128': 1.11.1
-      '@webassemblyjs/utf8': 1.11.1
+      '@webassemblyjs/ast': 1.11.6
+      '@webassemblyjs/helper-wasm-bytecode': 1.11.6
+      '@webassemblyjs/ieee754': 1.11.6
+      '@webassemblyjs/leb128': 1.11.6
+      '@webassemblyjs/utf8': 1.11.6
     dev: true
 
-  /@webassemblyjs/wasm-opt@1.11.1:
-    resolution: {integrity: sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw==}
+  /@webassemblyjs/wasm-opt@1.11.6:
+    resolution: {integrity: sha512-cOrKuLRE7PCe6AsOVl7WasYf3wbSo4CeOk6PkrjS7g57MFfVUF9u6ysQBBODX0LdgSvQqRiGz3CXvIDKcPNy4g==}
     dependencies:
-      '@webassemblyjs/ast': 1.11.1
-      '@webassemblyjs/helper-buffer': 1.11.1
-      '@webassemblyjs/wasm-gen': 1.11.1
-      '@webassemblyjs/wasm-parser': 1.11.1
+      '@webassemblyjs/ast': 1.11.6
+      '@webassemblyjs/helper-buffer': 1.11.6
+      '@webassemblyjs/wasm-gen': 1.11.6
+      '@webassemblyjs/wasm-parser': 1.11.6
     dev: true
 
-  /@webassemblyjs/wasm-parser@1.11.1:
-    resolution: {integrity: sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA==}
+  /@webassemblyjs/wasm-parser@1.11.6:
+    resolution: {integrity: sha512-6ZwPeGzMJM3Dqp3hCsLgESxBGtT/OeCvCZ4TA1JUPYgmhAx38tTPR9JaKy0S5H3evQpO/h2uWs2j6Yc/fjkpTQ==}
     dependencies:
-      '@webassemblyjs/ast': 1.11.1
-      '@webassemblyjs/helper-api-error': 1.11.1
-      '@webassemblyjs/helper-wasm-bytecode': 1.11.1
-      '@webassemblyjs/ieee754': 1.11.1
-      '@webassemblyjs/leb128': 1.11.1
-      '@webassemblyjs/utf8': 1.11.1
+      '@webassemblyjs/ast': 1.11.6
+      '@webassemblyjs/helper-api-error': 1.11.6
+      '@webassemblyjs/helper-wasm-bytecode': 1.11.6
+      '@webassemblyjs/ieee754': 1.11.6
+      '@webassemblyjs/leb128': 1.11.6
+      '@webassemblyjs/utf8': 1.11.6
     dev: true
 
-  /@webassemblyjs/wast-printer@1.11.1:
-    resolution: {integrity: sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg==}
+  /@webassemblyjs/wast-printer@1.11.6:
+    resolution: {integrity: sha512-JM7AhRcE+yW2GWYaKeHL5vt4xqee5N2WcezptmgyhNS+ScggqcT1OtXykhAb13Sn5Yas0j2uv9tHgrjwvzAP4A==}
     dependencies:
-      '@webassemblyjs/ast': 1.11.1
+      '@webassemblyjs/ast': 1.11.6
       '@xtuc/long': 4.2.2
     dev: true
 
-  /@webpack-cli/configtest@1.2.0(webpack-cli@4.10.0)(webpack@5.75.0):
+  /@webpack-cli/configtest@1.2.0(webpack-cli@4.10.0)(webpack@5.88.2):
     resolution: {integrity: sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg==}
     peerDependencies:
       webpack: 4.x.x || 5.x.x
       webpack-cli: 4.x.x
     dependencies:
-      webpack: 5.75.0(esbuild@0.19.0)(webpack-cli@4.10.0)
-      webpack-cli: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.75.0)
+      webpack: 5.88.2(esbuild@0.19.0)(webpack-cli@4.10.0)
+      webpack-cli: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.88.2)
     dev: true
 
   /@webpack-cli/info@1.5.0(webpack-cli@4.10.0):
@@ -5668,7 +5679,7 @@ packages:
       webpack-cli: 4.x.x
     dependencies:
       envinfo: 7.8.1
-      webpack-cli: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.75.0)
+      webpack-cli: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.88.2)
     dev: true
 
   /@webpack-cli/serve@1.7.0(webpack-cli@4.10.0)(webpack-dev-server@4.11.1):
@@ -5680,8 +5691,8 @@ packages:
       webpack-dev-server:
         optional: true
     dependencies:
-      webpack-cli: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.75.0)
-      webpack-dev-server: 4.11.1(webpack-cli@4.10.0)(webpack@5.75.0)
+      webpack-cli: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.88.2)
+      webpack-dev-server: 4.11.1(webpack-cli@4.10.0)(webpack@5.88.2)
     dev: true
 
   /@xtuc/ieee754@1.2.0:
@@ -5763,12 +5774,12 @@ packages:
       acorn-walk: 7.2.0
     dev: true
 
-  /acorn-import-assertions@1.8.0(acorn@8.8.0):
-    resolution: {integrity: sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==}
+  /acorn-import-assertions@1.9.0(acorn@8.10.0):
+    resolution: {integrity: sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==}
     peerDependencies:
       acorn: ^8
     dependencies:
-      acorn: 8.8.0
+      acorn: 8.10.0
     dev: true
 
   /acorn-jsx@5.3.2(acorn@8.10.0):
@@ -5800,12 +5811,6 @@ packages:
     hasBin: true
     dev: true
 
-  /acorn@8.8.0:
-    resolution: {integrity: sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==}
-    engines: {node: '>=0.4.0'}
-    hasBin: true
-    dev: true
-
   /acorn@8.8.2:
     resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==}
     engines: {node: '>=0.4.0'}
@@ -6161,7 +6166,7 @@ packages:
       - supports-color
     dev: true
 
-  /babel-loader@9.1.2(@babel/core@7.12.3)(webpack@5.75.0):
+  /babel-loader@9.1.2(@babel/core@7.12.3)(webpack@5.88.2):
     resolution: {integrity: sha512-mN14niXW43tddohGl8HPu5yfQq70iUThvFL/4QzESA7GcZoC0eVOhvWdQ8+3UlSjaDE9MVtsW9mxDY07W7VpVA==}
     engines: {node: '>= 14.15.0'}
     peerDependencies:
@@ -6171,7 +6176,7 @@ packages:
       '@babel/core': 7.12.3
       find-cache-dir: 3.3.2
       schema-utils: 4.0.0
-      webpack: 5.75.0(esbuild@0.19.0)(webpack-cli@4.10.0)
+      webpack: 5.88.2(esbuild@0.19.0)(webpack-cli@4.10.0)
     dev: true
 
   /babel-plugin-istanbul@6.1.1:
@@ -6388,17 +6393,6 @@ packages:
     resolution: {integrity: sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==}
     dev: true
 
-  /browserslist@4.21.4:
-    resolution: {integrity: sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw==}
-    engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
-    hasBin: true
-    dependencies:
-      caniuse-lite: 1.0.30001431
-      electron-to-chromium: 1.4.284
-      node-releases: 2.0.6
-      update-browserslist-db: 1.0.10(browserslist@4.21.4)
-    dev: true
-
   /browserslist@4.21.5:
     resolution: {integrity: sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==}
     engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
@@ -6546,10 +6540,6 @@ packages:
     engines: {node: '>=10'}
     dev: true
 
-  /caniuse-lite@1.0.30001431:
-    resolution: {integrity: sha512-zBUoFU0ZcxpvSt9IU66dXVT/3ctO1cy4y9cscs1szkPlcWb6pasYM144GqrUygUbT+k7cmUCW61cvskjcv0enQ==}
-    dev: true
-
   /caniuse-lite@1.0.30001457:
     resolution: {integrity: sha512-SDIV6bgE1aVbK6XyxdURbUE89zY7+k1BBBaOwYwkNCglXlel/E7mELiHC64HQ+W0xSKlqWhV9Wh7iHxUjMs4fA==}
     dev: true
@@ -8100,8 +8090,8 @@ packages:
       once: 1.4.0
     dev: true
 
-  /enhanced-resolve@5.10.0:
-    resolution: {integrity: sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==}
+  /enhanced-resolve@5.15.0:
+    resolution: {integrity: sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==}
     engines: {node: '>=10.13.0'}
     dependencies:
       graceful-fs: 4.2.10
@@ -8176,8 +8166,8 @@ packages:
       which-typed-array: 1.1.9
     dev: true
 
-  /es-module-lexer@0.9.3:
-    resolution: {integrity: sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==}
+  /es-module-lexer@1.3.0:
+    resolution: {integrity: sha512-vZK7T0N2CBmBOixhmjdqx2gWVbFZ4DXZ/NyRMZVlJXPa7CyFS+/a4QQsDGDQy9ZfEzxFuNEsMLeQJnKP2p5/JA==}
     dev: true
 
   /es-set-tostringtag@2.0.1:
@@ -12232,10 +12222,6 @@ packages:
     resolution: {integrity: sha512-5GFldHPXVG/YZmFzJvKK2zDSzPKhEp0+ZR5SVaoSag9fsL5YgHbUHDfnG5494ISANDcK4KwPXAx2xqVEydmd7w==}
     dev: true
 
-  /node-releases@2.0.6:
-    resolution: {integrity: sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==}
-    dev: true
-
   /nomnom@1.5.2:
     resolution: {integrity: sha512-fiVbT7BqxiQqjlR9U3FDGOSERFCKoXVCdxV2FwZuNN7/cmJ42iQx35nUFOAFDcyvemu9Adp+IlsCGlKQYLmBKw==}
     deprecated: Package no longer supported. Contact support@npmjs.com for more info.
@@ -13501,7 +13487,7 @@ packages:
       jest-worker: 26.6.2
       rollup: 2.79.1
       serialize-javascript: 4.0.0
-      terser: 5.15.1
+      terser: 5.19.2
     dev: true
 
   /rollup-plugin-visualizer@5.9.2:
@@ -13611,8 +13597,8 @@ packages:
       xmlchars: 2.2.0
     dev: true
 
-  /schema-utils@3.1.1:
-    resolution: {integrity: sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==}
+  /schema-utils@3.3.0:
+    resolution: {integrity: sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg==}
     engines: {node: '>= 10.13.0'}
     dependencies:
       '@types/json-schema': 7.0.11
@@ -13723,8 +13709,8 @@ packages:
       randombytes: 2.1.0
     dev: true
 
-  /serialize-javascript@6.0.0:
-    resolution: {integrity: sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==}
+  /serialize-javascript@6.0.1:
+    resolution: {integrity: sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==}
     dependencies:
       randombytes: 2.1.0
     dev: true
@@ -14421,8 +14407,8 @@ packages:
       iterm2-version: 4.2.0
     dev: true
 
-  /terser-webpack-plugin@5.3.6(esbuild@0.19.0)(webpack@5.75.0):
-    resolution: {integrity: sha512-kfLFk+PoLUQIbLmB1+PZDMRSZS99Mp+/MHqDNmMA6tOItzRt+Npe3E+fsMs5mfcM0wCtrrdU387UnV+vnSffXQ==}
+  /terser-webpack-plugin@5.3.9(esbuild@0.19.0)(webpack@5.88.2):
+    resolution: {integrity: sha512-ZuXsqE07EcggTWQjXUj+Aot/OMcD0bMKGgF63f7UxYcu5/AJF53aIpK1YoP5xR9l6s/Hy2b+t1AM0bLNPRuhwA==}
     engines: {node: '>= 10.13.0'}
     peerDependencies:
       '@swc/core': '*'
@@ -14440,18 +14426,18 @@ packages:
       '@jridgewell/trace-mapping': 0.3.17
       esbuild: 0.19.0
       jest-worker: 27.5.1
-      schema-utils: 3.1.1
-      serialize-javascript: 6.0.0
-      terser: 5.15.1
-      webpack: 5.75.0(esbuild@0.19.0)(webpack-cli@4.10.0)
+      schema-utils: 3.3.0
+      serialize-javascript: 6.0.1
+      terser: 5.19.2
+      webpack: 5.88.2(esbuild@0.19.0)(webpack-cli@4.10.0)
     dev: true
 
-  /terser@5.15.1:
-    resolution: {integrity: sha512-K1faMUvpm/FBxjBXud0LWVAGxmvoPbZbfTCYbSgaaYQaIXI3/TdI7a7ZGA73Zrou6Q8Zmz3oeUTsp/dj+ag2Xw==}
+  /terser@5.19.2:
+    resolution: {integrity: sha512-qC5+dmecKJA4cpYxRa5aVkKehYsQKc+AHeKl0Oe62aYjBL8ZA33tTljktDHJSaxxMnbI5ZYw+o/S2DxxLu8OfA==}
     engines: {node: '>=10'}
     hasBin: true
     dependencies:
-      '@jridgewell/source-map': 0.3.2
+      '@jridgewell/source-map': 0.3.5
       acorn: 8.10.0
       commander: 2.20.3
       source-map-support: 0.5.21
@@ -15005,11 +14991,11 @@ packages:
     engines: {node: '>= 10.0.0'}
     dev: true
 
-  /unocss@0.55.0(postcss@8.4.27)(rollup@2.79.1)(vite@4.3.9):
-    resolution: {integrity: sha512-mjtN/2Dr495swOA/u/UaA0keCtv8/vFc114pd0D4XzpbK2/nKNB9Got/lmhJp8fxblV+oNtLkD0PaHtpAvSpsw==}
+  /unocss@0.55.2(postcss@8.4.27)(rollup@2.79.1)(vite@4.3.9):
+    resolution: {integrity: sha512-+C8tFUFIEv40DpEhjA/Yv+RB5HZumkWiON2OlPyrbzapQ8x60F9TUwUS3pw7MlpxI6GfTCYwXKEE6DTGCm1SLA==}
     engines: {node: '>=14'}
     peerDependencies:
-      '@unocss/webpack': 0.55.0
+      '@unocss/webpack': 0.55.2
       vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0
     peerDependenciesMeta:
       '@unocss/webpack':
@@ -15017,26 +15003,26 @@ packages:
       vite:
         optional: true
     dependencies:
-      '@unocss/astro': 0.55.0(rollup@2.79.1)(vite@4.3.9)
-      '@unocss/cli': 0.55.0(rollup@2.79.1)
-      '@unocss/core': 0.55.0
-      '@unocss/extractor-arbitrary-variants': 0.55.0
-      '@unocss/postcss': 0.55.0(postcss@8.4.27)
-      '@unocss/preset-attributify': 0.55.0
-      '@unocss/preset-icons': 0.55.0
-      '@unocss/preset-mini': 0.55.0
-      '@unocss/preset-tagify': 0.55.0
-      '@unocss/preset-typography': 0.55.0
-      '@unocss/preset-uno': 0.55.0
-      '@unocss/preset-web-fonts': 0.55.0
-      '@unocss/preset-wind': 0.55.0
-      '@unocss/reset': 0.55.0
-      '@unocss/transformer-attributify-jsx': 0.55.0
-      '@unocss/transformer-attributify-jsx-babel': 0.55.0
-      '@unocss/transformer-compile-class': 0.55.0
-      '@unocss/transformer-directives': 0.55.0
-      '@unocss/transformer-variant-group': 0.55.0
-      '@unocss/vite': 0.55.0(rollup@2.79.1)(vite@4.3.9)
+      '@unocss/astro': 0.55.2(rollup@2.79.1)(vite@4.3.9)
+      '@unocss/cli': 0.55.2(rollup@2.79.1)
+      '@unocss/core': 0.55.2
+      '@unocss/extractor-arbitrary-variants': 0.55.2
+      '@unocss/postcss': 0.55.2(postcss@8.4.27)
+      '@unocss/preset-attributify': 0.55.2
+      '@unocss/preset-icons': 0.55.2
+      '@unocss/preset-mini': 0.55.2
+      '@unocss/preset-tagify': 0.55.2
+      '@unocss/preset-typography': 0.55.2
+      '@unocss/preset-uno': 0.55.2
+      '@unocss/preset-web-fonts': 0.55.2
+      '@unocss/preset-wind': 0.55.2
+      '@unocss/reset': 0.55.2
+      '@unocss/transformer-attributify-jsx': 0.55.2
+      '@unocss/transformer-attributify-jsx-babel': 0.55.2
+      '@unocss/transformer-compile-class': 0.55.2
+      '@unocss/transformer-directives': 0.55.2
+      '@unocss/transformer-variant-group': 0.55.2
+      '@unocss/vite': 0.55.2(rollup@2.79.1)(vite@4.3.9)
       vite: 4.3.9(@types/node@18.16.0)
     transitivePeerDependencies:
       - postcss
@@ -15097,17 +15083,6 @@ packages:
     engines: {node: '>=4'}
     dev: true
 
-  /update-browserslist-db@1.0.10(browserslist@4.21.4):
-    resolution: {integrity: sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==}
-    hasBin: true
-    peerDependencies:
-      browserslist: '>= 4.21.0'
-    dependencies:
-      browserslist: 4.21.4
-      escalade: 3.1.1
-      picocolors: 1.0.0
-    dev: true
-
   /update-browserslist-db@1.0.10(browserslist@4.21.5):
     resolution: {integrity: sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==}
     hasBin: true
@@ -15658,7 +15633,7 @@ packages:
     engines: {node: '>=12'}
     dev: true
 
-  /webpack-cli@4.10.0(webpack-dev-server@4.11.1)(webpack@5.75.0):
+  /webpack-cli@4.10.0(webpack-dev-server@4.11.1)(webpack@5.88.2):
     resolution: {integrity: sha512-NLhDfH/h4O6UOy+0LSso42xvYypClINuMNBVVzX4vX98TmTaTUxwRbXdhucbFMd2qLaCTcLq/PdYrvi8onw90w==}
     engines: {node: '>=10.13.0'}
     hasBin: true
@@ -15679,7 +15654,7 @@ packages:
         optional: true
     dependencies:
       '@discoveryjs/json-ext': 0.5.7
-      '@webpack-cli/configtest': 1.2.0(webpack-cli@4.10.0)(webpack@5.75.0)
+      '@webpack-cli/configtest': 1.2.0(webpack-cli@4.10.0)(webpack@5.88.2)
       '@webpack-cli/info': 1.5.0(webpack-cli@4.10.0)
       '@webpack-cli/serve': 1.7.0(webpack-cli@4.10.0)(webpack-dev-server@4.11.1)
       colorette: 2.0.19
@@ -15689,12 +15664,12 @@ packages:
       import-local: 3.1.0
       interpret: 2.2.0
       rechoir: 0.7.1
-      webpack: 5.75.0(esbuild@0.19.0)(webpack-cli@4.10.0)
-      webpack-dev-server: 4.11.1(webpack-cli@4.10.0)(webpack@5.75.0)
+      webpack: 5.88.2(esbuild@0.19.0)(webpack-cli@4.10.0)
+      webpack-dev-server: 4.11.1(webpack-cli@4.10.0)(webpack@5.88.2)
       webpack-merge: 5.8.0
     dev: true
 
-  /webpack-dev-middleware@5.3.3(webpack@5.75.0):
+  /webpack-dev-middleware@5.3.3(webpack@5.88.2):
     resolution: {integrity: sha512-hj5CYrY0bZLB+eTO+x/j67Pkrquiy7kWepMHmUMoPsmcUaeEnQJqFzHJOyxgWlq746/wUuA64p9ta34Kyb01pA==}
     engines: {node: '>= 12.13.0'}
     peerDependencies:
@@ -15705,10 +15680,10 @@ packages:
       mime-types: 2.1.35
       range-parser: 1.2.1
       schema-utils: 4.0.0
-      webpack: 5.75.0(esbuild@0.19.0)(webpack-cli@4.10.0)
+      webpack: 5.88.2(esbuild@0.19.0)(webpack-cli@4.10.0)
     dev: true
 
-  /webpack-dev-server@4.11.1(webpack-cli@4.10.0)(webpack@5.75.0):
+  /webpack-dev-server@4.11.1(webpack-cli@4.10.0)(webpack@5.88.2):
     resolution: {integrity: sha512-lILVz9tAUy1zGFwieuaQtYiadImb5M3d+H+L1zDYalYoDl0cksAB1UNyuE5MMWJrG6zR1tXkCP2fitl7yoUJiw==}
     engines: {node: '>= 12.13.0'}
     hasBin: true
@@ -15746,9 +15721,9 @@ packages:
       serve-index: 1.9.1
       sockjs: 0.3.24
       spdy: 4.0.2
-      webpack: 5.75.0(esbuild@0.19.0)(webpack-cli@4.10.0)
-      webpack-cli: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.75.0)
-      webpack-dev-middleware: 5.3.3(webpack@5.75.0)
+      webpack: 5.88.2(esbuild@0.19.0)(webpack-cli@4.10.0)
+      webpack-cli: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.88.2)
+      webpack-dev-middleware: 5.3.3(webpack@5.88.2)
       ws: 8.9.0
     transitivePeerDependencies:
       - bufferutil
@@ -15774,8 +15749,8 @@ packages:
     resolution: {integrity: sha512-kyDivFZ7ZM0BVOUteVbDFhlRt7Ah/CSPwJdi8hBpkK7QLumUqdLtVfm/PX/hkcnrvr0i77fO5+TjZ94Pe+C9iw==}
     dev: true
 
-  /webpack@5.75.0(esbuild@0.19.0)(webpack-cli@4.10.0):
-    resolution: {integrity: sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ==}
+  /webpack@5.88.2(esbuild@0.19.0)(webpack-cli@4.10.0):
+    resolution: {integrity: sha512-JmcgNZ1iKj+aiR0OvTYtWQqJwq37Pf683dY9bVORwVbUrDhLhdn/PlO2sHsFHPkj7sHNQF3JwaAkp49V+Sq1tQ==}
     engines: {node: '>=10.13.0'}
     hasBin: true
     peerDependencies:
@@ -15785,16 +15760,16 @@ packages:
         optional: true
     dependencies:
       '@types/eslint-scope': 3.7.4
-      '@types/estree': 0.0.51
-      '@webassemblyjs/ast': 1.11.1
-      '@webassemblyjs/wasm-edit': 1.11.1
-      '@webassemblyjs/wasm-parser': 1.11.1
-      acorn: 8.8.0
-      acorn-import-assertions: 1.8.0(acorn@8.8.0)
-      browserslist: 4.21.4
+      '@types/estree': 1.0.0
+      '@webassemblyjs/ast': 1.11.6
+      '@webassemblyjs/wasm-edit': 1.11.6
+      '@webassemblyjs/wasm-parser': 1.11.6
+      acorn: 8.10.0
+      acorn-import-assertions: 1.9.0(acorn@8.10.0)
+      browserslist: 4.21.5
       chrome-trace-event: 1.0.3
-      enhanced-resolve: 5.10.0
-      es-module-lexer: 0.9.3
+      enhanced-resolve: 5.15.0
+      es-module-lexer: 1.3.0
       eslint-scope: 5.1.1
       events: 3.3.0
       glob-to-regexp: 0.4.1
@@ -15803,11 +15778,11 @@ packages:
       loader-runner: 4.3.0
       mime-types: 2.1.35
       neo-async: 2.6.2
-      schema-utils: 3.1.1
+      schema-utils: 3.3.0
       tapable: 2.2.1
-      terser-webpack-plugin: 5.3.6(esbuild@0.19.0)(webpack@5.75.0)
+      terser-webpack-plugin: 5.3.9(esbuild@0.19.0)(webpack@5.88.2)
       watchpack: 2.4.0
-      webpack-cli: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.75.0)
+      webpack-cli: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.88.2)
       webpack-sources: 3.2.3
     transitivePeerDependencies:
       - '@swc/core'
diff --git a/tests/webpack/package.json b/tests/webpack/package.json
index e51845399..7f7bb5634 100644
--- a/tests/webpack/package.json
+++ b/tests/webpack/package.json
@@ -12,7 +12,7 @@
   "author": "",
   "license": "ISC",
   "devDependencies": {
-    "webpack": "^5.74.0",
+    "webpack": "^5.88.2",
     "webpack-cli": "^4.10.0",
     "webpack-dev-server": "^4.11.1"
   },

From a6e6c3fb1848bf37a001022324d7035a9f4e885d Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Mon, 21 Aug 2023 12:09:38 +0530
Subject: [PATCH 17/70] feat: Add support for config in frontmatter

---
 .../rendering/conf-and-directives.spec.js     | 70 ++++++++++++++++---
 packages/mermaid/src/Diagram.ts               |  2 +-
 packages/mermaid/src/config.ts                |  7 +-
 .../src/diagram-api/frontmatter.spec.ts       | 22 ++++++
 .../mermaid/src/diagram-api/frontmatter.ts    | 53 ++++++++------
 packages/mermaid/src/mermaidAPI.ts            |  8 ++-
 packages/mermaid/src/utils.ts                 | 36 ++++++----
 7 files changed, 150 insertions(+), 48 deletions(-)

diff --git a/cypress/integration/rendering/conf-and-directives.spec.js b/cypress/integration/rendering/conf-and-directives.spec.js
index bc17f6236..ca1fccf49 100644
--- a/cypress/integration/rendering/conf-and-directives.spec.js
+++ b/cypress/integration/rendering/conf-and-directives.spec.js
@@ -14,7 +14,6 @@ describe('Configuration and directives - nodes should be light blue', () => {
         `,
       {}
     );
-    cy.get('svg');
   });
   it('Settings from initialize - nodes should be green', () => {
     imgSnapshotTest(
@@ -28,7 +27,6 @@ graph TD
           end          `,
       { theme: 'forest' }
     );
-    cy.get('svg');
   });
   it('Settings from initialize overriding themeVariable - nodes should be red', () => {
     imgSnapshotTest(
@@ -46,7 +44,6 @@ graph TD
         `,
       { theme: 'base', themeVariables: { primaryColor: '#ff0000' }, logLevel: 0 }
     );
-    cy.get('svg');
   });
   it('Settings from directive - nodes should be grey', () => {
     imgSnapshotTest(
@@ -62,7 +59,24 @@ graph TD
         `,
       {}
     );
-    cy.get('svg');
+  });
+  it('Settings from frontmatter - nodes should be grey', () => {
+    imgSnapshotTest(
+      `
+---
+config:
+  theme: neutral
+---
+graph TD
+          A(Start) --> B[/Another/]
+          A[/Another/] --> C[End]
+          subgraph section
+            B
+            C
+          end
+        `,
+      {}
+    );
   });
 
   it('Settings from directive overriding theme variable - nodes should be red', () => {
@@ -79,7 +93,6 @@ graph TD
         `,
       {}
     );
-    cy.get('svg');
   });
   it('Settings from initialize and directive - nodes should be grey', () => {
     imgSnapshotTest(
@@ -95,7 +108,6 @@ graph TD
         `,
       { theme: 'forest' }
     );
-    cy.get('svg');
   });
   it('Theme from initialize, directive overriding theme variable - nodes should be red', () => {
     imgSnapshotTest(
@@ -111,8 +123,50 @@ graph TD
         `,
       { theme: 'base' }
     );
-    cy.get('svg');
   });
+  it('Theme from initialize, frontmatter overriding theme variable - nodes should be red', () => {
+    imgSnapshotTest(
+      `
+---
+config:
+  theme: base
+  themeVariables:
+    primaryColor: '#ff0000'
+---
+graph TD
+          A(Start) --> B[/Another/]
+          A[/Another/] --> C[End]
+          subgraph section
+            B
+            C
+          end
+        `,
+      { theme: 'forest' }
+    );
+  });
+
+  it('should render if values are not quoted properly', () => {
+    // #ff0000 is not quoted properly, and will evaluate to null.
+    // This test ensures that the rendering still works.
+    imgSnapshotTest(
+      `---
+config:
+  theme: base
+  themeVariables:
+    primaryColor: #ff0000
+---
+graph TD
+          A(Start) --> B[/Another/]
+          A[/Another/] --> C[End]
+          subgraph section
+            B
+            C
+          end
+        `,
+      { theme: 'forest' }
+    );
+  });
+
   it('Theme variable from initialize, theme from directive - nodes should be red', () => {
     imgSnapshotTest(
       `
@@ -127,13 +181,11 @@ graph TD
         `,
       { themeVariables: { primaryColor: '#ff0000' } }
     );
-    cy.get('svg');
   });
   describe('when rendering several diagrams', () => {
     it('diagrams should not taint later diagrams', () => {
       const url = 'http://localhost:9000/theme-directives.html';
       cy.visit(url);
-      cy.get('svg');
       cy.matchImageSnapshot('conf-and-directives.spec-when-rendering-several-diagrams-diagram-1');
     });
   });
diff --git a/packages/mermaid/src/Diagram.ts b/packages/mermaid/src/Diagram.ts
index 13fd3232b..308e141d0 100644
--- a/packages/mermaid/src/Diagram.ts
+++ b/packages/mermaid/src/Diagram.ts
@@ -48,7 +48,7 @@ export class Diagram {
     // extractFrontMatter().
 
     this.parser.parse = (text: string) =>
-      originalParse(cleanupComments(extractFrontMatter(text, this.db)));
+      originalParse(cleanupComments(extractFrontMatter(text, this.db, configApi.addDirective)));
 
     this.parser.parser.yy = this.db;
     this.init = diagram.init;
diff --git a/packages/mermaid/src/config.ts b/packages/mermaid/src/config.ts
index c426e9122..eb24b6268 100644
--- a/packages/mermaid/src/config.ts
+++ b/packages/mermaid/src/config.ts
@@ -144,9 +144,12 @@ export const getConfig = (): MermaidConfig => {
  * @param options - The potential setConfig parameter
  */
 export const sanitize = (options: any) => {
+  if (!options) {
+    return;
+  }
   // Checking that options are not in the list of excluded options
   ['secure', ...(siteConfig.secure ?? [])].forEach((key) => {
-    if (options[key] !== undefined) {
+    if (Object.hasOwn(options, key)) {
       // DO NOT attempt to print options[key] within `${}` as a malicious script
       // can exploit the logger's attempt to stringify the value and execute arbitrary code
       log.debug(`Denied attempt to modify a secure key ${key}`, options[key]);
@@ -156,7 +159,7 @@ export const sanitize = (options: any) => {
 
   // Check that there no attempts of prototype pollution
   Object.keys(options).forEach((key) => {
-    if (key.indexOf('__') === 0) {
+    if (key.startsWith('__')) {
       delete options[key];
     }
   });
diff --git a/packages/mermaid/src/diagram-api/frontmatter.spec.ts b/packages/mermaid/src/diagram-api/frontmatter.spec.ts
index ef05c8f14..03d46c300 100644
--- a/packages/mermaid/src/diagram-api/frontmatter.spec.ts
+++ b/packages/mermaid/src/diagram-api/frontmatter.spec.ts
@@ -2,8 +2,13 @@ import { vi } from 'vitest';
 import { extractFrontMatter } from './frontmatter.js';
 
 const dbMock = () => ({ setDiagramTitle: vi.fn() });
+const setConfigMock = vi.fn();
 
 describe('extractFrontmatter', () => {
+  beforeEach(() => {
+    setConfigMock.mockClear();
+  });
+
   it('returns text unchanged if no frontmatter', () => {
     expect(extractFrontMatter('diagram', dbMock())).toEqual('diagram');
   });
@@ -75,4 +80,21 @@ describe('extractFrontmatter', () => {
       'tag suffix cannot contain exclamation marks'
     );
   });
+
+  it('handles frontmatter with config', () => {
+    const text = `---
+title: hello
+config:
+  graph:
+    string: hello
+    number: 14
+    boolean: false
+    array: [1, 2, 3]
+---
+diagram`;
+    expect(extractFrontMatter(text, {}, setConfigMock)).toEqual('diagram');
+    expect(setConfigMock).toHaveBeenCalledWith({
+      graph: { string: 'hello', number: 14, boolean: false, array: [1, 2, 3] },
+    });
+  });
 });
diff --git a/packages/mermaid/src/diagram-api/frontmatter.ts b/packages/mermaid/src/diagram-api/frontmatter.ts
index f8d2e9c41..1ce673d4f 100644
--- a/packages/mermaid/src/diagram-api/frontmatter.ts
+++ b/packages/mermaid/src/diagram-api/frontmatter.ts
@@ -1,3 +1,4 @@
+import { MermaidConfig } from '../config.type.js';
 import { DiagramDB } from './types.js';
 // The "* as yaml" part is necessary for tree-shaking
 import * as yaml from 'js-yaml';
@@ -9,38 +10,50 @@ import * as yaml from 'js-yaml';
 // Relevant YAML spec: https://yaml.org/spec/1.2.2/#914-explicit-documents
 export const frontMatterRegex = /^-{3}\s*[\n\r](.*?)[\n\r]-{3}\s*[\n\r]+/s;
 
-type FrontMatterMetadata = {
+interface FrontMatterMetadata {
   title?: string;
   // Allows custom display modes. Currently used for compact mode in gantt charts.
   displayMode?: string;
-};
+  config?: MermaidConfig;
+}
 
 /**
  * Extract and parse frontmatter from text, if present, and sets appropriate
  * properties in the provided db.
  * @param text - The text that may have a YAML frontmatter.
  * @param db - Diagram database, could be of any diagram.
+ * @param setDiagramConfig - Optional function to set diagram config.
  * @returns text with frontmatter stripped out
  */
-export function extractFrontMatter(text: string, db: DiagramDB): string {
+export function extractFrontMatter(
+  text: string,
+  db: DiagramDB,
+  setDiagramConfig?: (config: MermaidConfig) => void
+): string {
   const matches = text.match(frontMatterRegex);
-  if (matches) {
-    const parsed: FrontMatterMetadata = yaml.load(matches[1], {
-      // To keep things simple, only allow strings, arrays, and plain objects.
-      // https://www.yaml.org/spec/1.2/spec.html#id2802346
-      schema: yaml.FAILSAFE_SCHEMA,
-    }) as FrontMatterMetadata;
-
-    if (parsed?.title) {
-      db.setDiagramTitle?.(parsed.title);
-    }
-
-    if (parsed?.displayMode) {
-      db.setDisplayMode?.(parsed.displayMode);
-    }
-
-    return text.slice(matches[0].length);
-  } else {
+  if (!matches) {
     return text;
   }
+
+  const parsed: FrontMatterMetadata = yaml.load(matches[1], {
+    // To support config, we need JSON schema.
+    // https://www.yaml.org/spec/1.2/spec.html#id2803231
+    schema: yaml.JSON_SCHEMA,
+  }) as FrontMatterMetadata;
+
+  if (parsed?.title) {
+    // toString() is necessary because YAML could parse the title as a number/boolean
+    db.setDiagramTitle?.(parsed.title.toString());
+  }
+
+  if (parsed?.displayMode) {
+    // toString() is necessary because YAML could parse the title as a number/boolean
+    db.setDisplayMode?.(parsed.displayMode.toString());
+  }
+
+  if (parsed?.config) {
+    setDiagramConfig?.(parsed.config);
+  }
+
+  return text.slice(matches[0].length);
 }
diff --git a/packages/mermaid/src/mermaidAPI.ts b/packages/mermaid/src/mermaidAPI.ts
index 35b251bc7..0a5fae575 100644
--- a/packages/mermaid/src/mermaidAPI.ts
+++ b/packages/mermaid/src/mermaidAPI.ts
@@ -30,6 +30,7 @@ import { evaluate } from './diagrams/common/common.js';
 import isEmpty from 'lodash-es/isEmpty.js';
 import { setA11yDiagramInfo, addSVGa11yTitleDescription } from './accessibility.js';
 import { parseDirective } from './directiveUtils.js';
+import { extractFrontMatter } from './diagram-api/frontmatter.js';
 
 // diagram names that support classDef statements
 const CLASSDEF_DIAGRAMS = [
@@ -385,7 +386,12 @@ const render = async function (
 
   configApi.reset();
 
-  // Add Directives. Must do this before getting the config and before creating the diagram.
+  // We need to add the directives before creating the diagram.
+  // So extractFrontMatter is called twice. Once here and once in the diagram parser.
+  // This can be fixed in a future refactor.
+  extractFrontMatter(text, {}, configApi.addDirective);
+
+  // Add Directives.
   const graphInit = utils.detectInit(text);
   if (graphInit) {
     configApi.addDirective(graphInit);
diff --git a/packages/mermaid/src/utils.ts b/packages/mermaid/src/utils.ts
index dd574f86a..cae3d5bfe 100644
--- a/packages/mermaid/src/utils.ts
+++ b/packages/mermaid/src/utils.ts
@@ -96,7 +96,10 @@ const directiveWithoutOpen =
  * @param config - Optional mermaid configuration object.
  * @returns The json object representing the init passed to mermaid.initialize()
  */
-export const detectInit = function (text: string, config?: MermaidConfig): MermaidConfig {
+export const detectInit = function (
+  text: string,
+  config?: MermaidConfig
+): MermaidConfig | undefined {
   const inits = detectDirective(text, /(?:init\b)|(?:initialize\b)/);
   let results = {};
 
@@ -106,20 +109,22 @@ export const detectInit = function (text: string, config?: MermaidConfig): Merma
   } else {
     results = inits.args;
   }
-  if (results) {
-    let type = detectType(text, config);
-    ['config'].forEach((prop) => {
-      if (results[prop] !== undefined) {
-        if (type === 'flowchart-v2') {
-          type = 'flowchart';
-        }
-        results[type] = results[prop];
-        delete results[prop];
-      }
-    });
+
+  if (!results) {
+    return;
   }
 
-  // Todo: refactor this, these results are never used
+  let type = detectType(text, config);
+  ['config'].forEach((prop) => {
+    if (results[prop] !== undefined) {
+      if (type === 'flowchart-v2') {
+        type = 'flowchart';
+      }
+      results[type] = results[prop];
+      delete results[prop];
+    }
+  });
+
   return results;
 };
 
@@ -844,7 +849,7 @@ export const sanitizeDirective = (args: unknown): void => {
   log.debug('sanitizeDirective called with', args);
 
   // Return if not an object
-  if (typeof args !== 'object') {
+  if (typeof args !== 'object' || args == null) {
     return;
   }
 
@@ -861,7 +866,8 @@ export const sanitizeDirective = (args: unknown): void => {
       key.startsWith('__') ||
       key.includes('proto') ||
       key.includes('constr') ||
-      !configKeys.has(key)
+      !configKeys.has(key) ||
+      args[key] == null
     ) {
       log.debug('sanitize deleting key: ', key);
       delete args[key];

From fd35a5473568be0aad9fb1db6510a4b249daf0fc Mon Sep 17 00:00:00 2001
From: sidharthv96 
Date: Mon, 21 Aug 2023 06:43:15 +0000
Subject: [PATCH 18/70] Update docs

---
 .../interfaces/mermaidAPI.ParseOptions.md     |  2 +-
 .../interfaces/mermaidAPI.RenderResult.md     |  4 +--
 docs/config/setup/modules/config.md           | 26 +++++++++----------
 docs/config/setup/modules/defaultConfig.md    |  2 +-
 docs/config/setup/modules/mermaidAPI.md       | 22 ++++++++--------
 5 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/docs/config/setup/interfaces/mermaidAPI.ParseOptions.md b/docs/config/setup/interfaces/mermaidAPI.ParseOptions.md
index 8ab259885..2082a081e 100644
--- a/docs/config/setup/interfaces/mermaidAPI.ParseOptions.md
+++ b/docs/config/setup/interfaces/mermaidAPI.ParseOptions.md
@@ -16,4 +16,4 @@
 
 #### Defined in
 
-[mermaidAPI.ts:77](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L77)
+[mermaidAPI.ts:78](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L78)
diff --git a/docs/config/setup/interfaces/mermaidAPI.RenderResult.md b/docs/config/setup/interfaces/mermaidAPI.RenderResult.md
index 527b46d09..f84a51b87 100644
--- a/docs/config/setup/interfaces/mermaidAPI.RenderResult.md
+++ b/docs/config/setup/interfaces/mermaidAPI.RenderResult.md
@@ -39,7 +39,7 @@ bindFunctions?.(div); // To call bindFunctions only if it's present.
 
 #### Defined in
 
-[mermaidAPI.ts:97](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L97)
+[mermaidAPI.ts:98](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L98)
 
 ---
 
@@ -51,4 +51,4 @@ The svg code for the rendered graph.
 
 #### Defined in
 
-[mermaidAPI.ts:87](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L87)
+[mermaidAPI.ts:88](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L88)
diff --git a/docs/config/setup/modules/config.md b/docs/config/setup/modules/config.md
index 8381dc8c7..f1de64e2d 100644
--- a/docs/config/setup/modules/config.md
+++ b/docs/config/setup/modules/config.md
@@ -14,7 +14,7 @@
 
 #### Defined in
 
-[config.ts:7](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L7)
+[config.ts:8](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L8)
 
 ## Functions
 
@@ -26,9 +26,9 @@ Pushes in a directive to the configuration
 
 #### Parameters
 
-| Name        | Type  | Description              |
-| :---------- | :---- | :----------------------- |
-| `directive` | `any` | The directive to push in |
+| Name        | Type            | Description              |
+| :---------- | :-------------- | :----------------------- |
+| `directive` | `MermaidConfig` | The directive to push in |
 
 #### Returns
 
@@ -36,7 +36,7 @@ Pushes in a directive to the configuration
 
 #### Defined in
 
-[config.ts:191](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L191)
+[config.ts:188](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L188)
 
 ---
 
@@ -60,7 +60,7 @@ The currentConfig
 
 #### Defined in
 
-[config.ts:137](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L137)
+[config.ts:131](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L131)
 
 ---
 
@@ -118,7 +118,7 @@ The siteConfig
 
 #### Defined in
 
-[config.ts:223](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L223)
+[config.ts:218](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L218)
 
 ---
 
@@ -147,7 +147,7 @@ options in-place
 
 #### Defined in
 
-[config.ts:152](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L152)
+[config.ts:146](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L146)
 
 ---
 
@@ -242,10 +242,10 @@ The new siteConfig
 
 #### Parameters
 
-| Name          | Type            |
-| :------------ | :-------------- |
-| `siteCfg`     | `MermaidConfig` |
-| `_directives` | `any`\[]        |
+| Name          | Type               |
+| :------------ | :----------------- |
+| `siteCfg`     | `MermaidConfig`    |
+| `_directives` | `MermaidConfig`\[] |
 
 #### Returns
 
@@ -253,7 +253,7 @@ The new siteConfig
 
 #### Defined in
 
-[config.ts:14](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L14)
+[config.ts:15](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L15)
 
 ---
 
diff --git a/docs/config/setup/modules/defaultConfig.md b/docs/config/setup/modules/defaultConfig.md
index 2d23977fe..effaec7b1 100644
--- a/docs/config/setup/modules/defaultConfig.md
+++ b/docs/config/setup/modules/defaultConfig.md
@@ -10,7 +10,7 @@
 
 ### configKeys
 
-• `Const` **configKeys**: `string`\[]
+• `Const` **configKeys**: `Set`<`string`>
 
 #### Defined in
 
diff --git a/docs/config/setup/modules/mermaidAPI.md b/docs/config/setup/modules/mermaidAPI.md
index 1160a5dda..d5d4a1cbc 100644
--- a/docs/config/setup/modules/mermaidAPI.md
+++ b/docs/config/setup/modules/mermaidAPI.md
@@ -25,7 +25,7 @@ Renames and re-exports [mermaidAPI](mermaidAPI.md#mermaidapi)
 
 #### Defined in
 
-[mermaidAPI.ts:81](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L81)
+[mermaidAPI.ts:82](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L82)
 
 ## Variables
 
@@ -96,7 +96,7 @@ mermaid.initialize(config);
 
 #### Defined in
 
-[mermaidAPI.ts:668](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L668)
+[mermaidAPI.ts:673](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L673)
 
 ## Functions
 
@@ -127,7 +127,7 @@ Return the last node appended
 
 #### Defined in
 
-[mermaidAPI.ts:309](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L309)
+[mermaidAPI.ts:310](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L310)
 
 ---
 
@@ -153,7 +153,7 @@ the cleaned up svgCode
 
 #### Defined in
 
-[mermaidAPI.ts:255](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L255)
+[mermaidAPI.ts:256](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L256)
 
 ---
 
@@ -179,7 +179,7 @@ the string with all the user styles
 
 #### Defined in
 
-[mermaidAPI.ts:184](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L184)
+[mermaidAPI.ts:185](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L185)
 
 ---
 
@@ -202,7 +202,7 @@ the string with all the user styles
 
 #### Defined in
 
-[mermaidAPI.ts:232](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L232)
+[mermaidAPI.ts:233](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L233)
 
 ---
 
@@ -229,7 +229,7 @@ with an enclosing block that has each of the cssClasses followed by !important;
 
 #### Defined in
 
-[mermaidAPI.ts:168](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L168)
+[mermaidAPI.ts:169](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L169)
 
 ---
 
@@ -249,7 +249,7 @@ with an enclosing block that has each of the cssClasses followed by !important;
 
 #### Defined in
 
-[mermaidAPI.ts:154](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L154)
+[mermaidAPI.ts:155](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L155)
 
 ---
 
@@ -269,7 +269,7 @@ with an enclosing block that has each of the cssClasses followed by !important;
 
 #### Defined in
 
-[mermaidAPI.ts:125](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L125)
+[mermaidAPI.ts:126](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L126)
 
 ---
 
@@ -295,7 +295,7 @@ Put the svgCode into an iFrame. Return the iFrame code
 
 #### Defined in
 
-[mermaidAPI.ts:286](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L286)
+[mermaidAPI.ts:287](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L287)
 
 ---
 
@@ -320,4 +320,4 @@ Remove any existing elements from the given document
 
 #### Defined in
 
-[mermaidAPI.ts:359](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L359)
+[mermaidAPI.ts:360](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L360)

From 844a175039f5ba563cad9eac2d16cd6e247c2235 Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Mon, 21 Aug 2023 12:30:04 +0530
Subject: [PATCH 19/70] chore: Add test with both frontmatter and directive

---
 .../rendering/conf-and-directives.spec.js     | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/cypress/integration/rendering/conf-and-directives.spec.js b/cypress/integration/rendering/conf-and-directives.spec.js
index ca1fccf49..401a24894 100644
--- a/cypress/integration/rendering/conf-and-directives.spec.js
+++ b/cypress/integration/rendering/conf-and-directives.spec.js
@@ -133,6 +133,27 @@ config:
   themeVariables:
     primaryColor: '#ff0000'
 ---
+graph TD
+          A(Start) --> B[/Another/]
+          A[/Another/] --> C[End]
+          subgraph section
+            B
+            C
+          end
+        `,
+      { theme: 'forest' }
+    );
+  });
+  it('Theme from initialize, frontmatter overriding theme variable, directive overriding primaryColor - nodes should be red', () => {
+    imgSnapshotTest(
+      `
+---
+config:
+  theme: base
+  themeVariables:
+    primaryColor: '#00ff00'
+---
+%%{init: {'theme': 'base', 'themeVariables':{ 'primaryColor': '#ff0000'}}}%%
 graph TD
           A(Start) --> B[/Another/]
           A[/Another/] --> C[End]

From 534fd85339ffd283b0f6b89725ff00185df95c5f Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Mon, 21 Aug 2023 12:53:29 +0530
Subject: [PATCH 20/70] chore: Minor typo fixes

---
 packages/mermaid/src/schemas/config.schema.yaml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/packages/mermaid/src/schemas/config.schema.yaml b/packages/mermaid/src/schemas/config.schema.yaml
index 6e5f48d95..29e745562 100644
--- a/packages/mermaid/src/schemas/config.schema.yaml
+++ b/packages/mermaid/src/schemas/config.schema.yaml
@@ -13,10 +13,10 @@
 #     Non-JSON values, like functions or `undefined`, still need to be manually
 #     set in `src/defaultConfig.ts`)
 #   - `src/docs.mts`
-#     Used to genereate Markdown documentation for this JSON Schema by using
+#     Used to generate Markdown documentation for this JSON Schema by using
 #     the `@adobe/jsonschema2md` NPM package.
 
-# Useful things to know when editting this file
+# Useful things to know when editing this file
 # - Use the `|` character for multi-line strings
 # - Use `meta:enum` to document enum values (from jsonschema2md)
 # - Use `tsType` to override the TypeScript type (from json-schema-to-typescript)
@@ -1851,7 +1851,7 @@ $defs: # JSON Schema definition (maybe we should move these to a seperate file)
           The color of the links in the sankey diagram.
         anyOf:
           - $ref: '#/$defs/SankeyLinkColor'
-          - description: An arbtirary [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value)
+          - description: An arbitrary [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value)
             type: string
         default: gradient
       nodeAlignment:

From 2967b3c1bb5608b04bfcbe72f942094fe3877116 Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Mon, 21 Aug 2023 14:25:25 +0530
Subject: [PATCH 21/70] fix: XSS vulnerability

---
 packages/mermaid/src/utils.ts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/packages/mermaid/src/utils.ts b/packages/mermaid/src/utils.ts
index cae3d5bfe..4f9cedebd 100644
--- a/packages/mermaid/src/utils.ts
+++ b/packages/mermaid/src/utils.ts
@@ -105,6 +105,7 @@ export const detectInit = function (
 
   if (Array.isArray(inits)) {
     const args = inits.map((init) => init.args);
+    sanitizeDirective(args);
     results = assignWithDepth(results, [...args]);
   } else {
     results = inits.args;

From 8ac7dc81e08deb8b2659fa8af6275d0646a5f15f Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Mon, 21 Aug 2023 15:02:05 +0530
Subject: [PATCH 22/70] docs: Add frontmatter config docs

---
 cSpell.json                                   |  1 +
 docs/config/configuration.md                  | 33 ++++++++++++++++++-
 docs/config/directives.md                     |  3 ++
 docs/config/setup/modules/config.md           |  2 +-
 .../mermaid/src/docs/config/configuration.md  | 20 ++++++++++-
 .../mermaid/src/docs/config/directives.md     |  4 +++
 6 files changed, 60 insertions(+), 3 deletions(-)

diff --git a/cSpell.json b/cSpell.json
index af7a9ca46..52012a337 100644
--- a/cSpell.json
+++ b/cSpell.json
@@ -44,6 +44,7 @@
     "faber",
     "flatmap",
     "foswiki",
+    "frontmatter",
     "ftplugin",
     "gantt",
     "gitea",
diff --git a/docs/config/configuration.md b/docs/config/configuration.md
index c7b780143..1e85427ea 100644
--- a/docs/config/configuration.md
+++ b/docs/config/configuration.md
@@ -10,10 +10,41 @@ When mermaid starts, configuration is extracted to determine a configuration to
 
 - The default configuration
 - Overrides at the site level are set by the initialize call, and will be applied to all diagrams in the site/app. The term for this is the **siteConfig**.
-- Directives - diagram authors can update select configuration parameters directly in the diagram code via directives. These are applied to the render config.
+- Frontmatter (v\+) - diagram authors can update select configuration parameters in the frontmatter of the diagram. These are applied to the render config.
+- Directives (Deprecated by Frontmatter) - diagram authors can update select configuration parameters directly in the diagram code via directives. These are applied to the render config.
 
 **The render config** is configuration that is used when rendering by applying these configurations.
 
+## Frontmatter config
+
+The entire mermaid configuration (except the secure configs) can be overridden by the diagram author in the frontmatter of the diagram. The frontmatter is a YAML block at the top of the diagram.
+
+```mermaid-example
+---
+title: Hello Title
+config:
+  theme: base
+  themeVariables:
+    primaryColor: "#00ff00"
+---
+flowchart
+	Hello --> World
+
+```
+
+```mermaid
+---
+title: Hello Title
+config:
+  theme: base
+  themeVariables:
+    primaryColor: "#00ff00"
+---
+flowchart
+	Hello --> World
+
+```
+
 ## Theme configuration
 
 ## Starting mermaid
diff --git a/docs/config/directives.md b/docs/config/directives.md
index 27fd767c7..414565d53 100644
--- a/docs/config/directives.md
+++ b/docs/config/directives.md
@@ -6,6 +6,9 @@
 
 # Directives
 
+> **Warning**
+> Directives are deprecated from v\. Please use the `config` key in frontmatter to pass configuration. See [Configuration](./configuration.md) for more details.
+
 ## Directives
 
 Directives give a diagram author the capability to alter the appearance of a diagram before rendering by changing the applied configuration.
diff --git a/docs/config/setup/modules/config.md b/docs/config/setup/modules/config.md
index f1de64e2d..e779224c1 100644
--- a/docs/config/setup/modules/config.md
+++ b/docs/config/setup/modules/config.md
@@ -118,7 +118,7 @@ The siteConfig
 
 #### Defined in
 
-[config.ts:218](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L218)
+[config.ts:217](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L217)
 
 ---
 
diff --git a/packages/mermaid/src/docs/config/configuration.md b/packages/mermaid/src/docs/config/configuration.md
index d248944dd..e52f2c6d5 100644
--- a/packages/mermaid/src/docs/config/configuration.md
+++ b/packages/mermaid/src/docs/config/configuration.md
@@ -4,10 +4,28 @@ When mermaid starts, configuration is extracted to determine a configuration to
 
 - The default configuration
 - Overrides at the site level are set by the initialize call, and will be applied to all diagrams in the site/app. The term for this is the **siteConfig**.
-- Directives - diagram authors can update select configuration parameters directly in the diagram code via directives. These are applied to the render config.
+- Frontmatter (v+) - diagram authors can update select configuration parameters in the frontmatter of the diagram. These are applied to the render config.
+- Directives (Deprecated by Frontmatter) - diagram authors can update select configuration parameters directly in the diagram code via directives. These are applied to the render config.
 
 **The render config** is configuration that is used when rendering by applying these configurations.
 
+## Frontmatter config
+
+The entire mermaid configuration (except the secure configs) can be overridden by the diagram author in the frontmatter of the diagram. The frontmatter is a YAML block at the top of the diagram.
+
+```mermaid-example
+---
+title: Hello Title
+config:
+  theme: base
+  themeVariables:
+    primaryColor: "#00ff00"
+---
+flowchart
+	Hello --> World
+
+```
+
 ## Theme configuration
 
 ## Starting mermaid
diff --git a/packages/mermaid/src/docs/config/directives.md b/packages/mermaid/src/docs/config/directives.md
index c85d1d245..5ce9fba6d 100644
--- a/packages/mermaid/src/docs/config/directives.md
+++ b/packages/mermaid/src/docs/config/directives.md
@@ -1,5 +1,9 @@
 # Directives
 
+```warning
+Directives are deprecated from v. Please use the `config` key in frontmatter to pass configuration. See [Configuration](./configuration.md) for more details.
+```
+
 ## Directives
 
 Directives give a diagram author the capability to alter the appearance of a diagram before rendering by changing the applied configuration.

From 2b9dc0ea80ce1ef3df06a44e53a8ac6b3b650b85 Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Mon, 21 Aug 2023 15:02:29 +0530
Subject: [PATCH 23/70] docs: Add frontmatter config demos

---
 demos/er.html        | 2 ++
 demos/flowchart.html | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/demos/er.html b/demos/er.html
index 49f0a683f..65e3049c8 100644
--- a/demos/er.html
+++ b/demos/er.html
@@ -21,6 +21,8 @@
     
       ---
       title: This is a title
+      config:
+        theme: forest
       ---
       erDiagram
         %% title This is a title
diff --git a/demos/flowchart.html b/demos/flowchart.html
index 92c5bbd6e..8389510b2 100644
--- a/demos/flowchart.html
+++ b/demos/flowchart.html
@@ -123,6 +123,13 @@
 
     

flowchart

+    ---
+    title: This is another complicated flow
+    config:
+      theme: base
+      flowchart:
+        curve: cardinal
+    ---
     flowchart LR
     sid-B3655226-6C29-4D00-B685-3D5C734DC7E1["
 

From 5c9eafabae396813511e3cd0efd3ba599189e147 Mon Sep 17 00:00:00 2001
From: sidharthv96 
Date: Mon, 21 Aug 2023 09:36:24 +0000
Subject: [PATCH 24/70] Update docs

---
 docs/config/setup/modules/config.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/config/setup/modules/config.md b/docs/config/setup/modules/config.md
index e779224c1..f1de64e2d 100644
--- a/docs/config/setup/modules/config.md
+++ b/docs/config/setup/modules/config.md
@@ -118,7 +118,7 @@ The siteConfig
 
 #### Defined in
 
-[config.ts:217](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L217)
+[config.ts:218](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L218)
 
 ---
 

From e5315f29335da4d0391994bd5b1e38bc4474925c Mon Sep 17 00:00:00 2001
From: Tom PERRILLAT-COLLOMB 
Date: Mon, 21 Aug 2023 23:33:42 +0200
Subject: [PATCH 25/70] feat(er): add entity name alias

---
 demos/er.html                                 | 14 ++++++++++
 docs/syntax/entityRelationshipDiagram.md      | 28 +++++++++++++++++++
 packages/mermaid/src/diagrams/er/erDb.js      |  4 +--
 .../mermaid/src/diagrams/er/erRenderer.js     |  2 +-
 .../src/diagrams/er/parser/erDiagram.jison    | 10 +++++++
 .../src/diagrams/er/parser/erDiagram.spec.js  |  9 ++++++
 .../docs/syntax/entityRelationshipDiagram.md  | 16 +++++++++++
 7 files changed, 80 insertions(+), 3 deletions(-)

diff --git a/demos/er.html b/demos/er.html
index 49f0a683f..f1233e19f 100644
--- a/demos/er.html
+++ b/demos/er.html
@@ -108,6 +108,20 @@
         }
         MANUFACTURER only one to zero or more CAR : makes
     
+
+ +
+    erDiagram
+      p as Person {
+        string firstName
+        string lastName
+      }
+      a as "Customer Account" {
+        string email
+      }
+      p ||--o| a : has
+    
+
From a7ae1b68905a5fb1c97cd975d5cce68e3e31b3f0 Mon Sep 17 00:00:00 2001 From: Tom PERRILLAT-COLLOMB Date: Tue, 22 Aug 2023 11:05:09 +0200 Subject: [PATCH 33/70] feat(er): use square brackets to add aliases --- demos/er.html | 10 +++++----- docs/syntax/entityRelationshipDiagram.md | 10 +++++----- .../mermaid/src/diagrams/er/parser/erDiagram.jison | 11 ++++++----- .../mermaid/src/diagrams/er/parser/erDiagram.spec.js | 2 +- .../src/docs/syntax/entityRelationshipDiagram.md | 6 +++--- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/demos/er.html b/demos/er.html index f1233e19f..eabae6acf 100644 --- a/demos/er.html +++ b/demos/er.html @@ -112,12 +112,12 @@
     erDiagram
-      p as Person {
-        string firstName
-        string lastName
+      p[Person] {
+          string firstName
+          string lastName
       }
-      a as "Customer Account" {
-        string email
+      a["Customer Account"] {
+          string email
       }
       p ||--o| a : has
     
diff --git a/docs/syntax/entityRelationshipDiagram.md b/docs/syntax/entityRelationshipDiagram.md index 5bc8df436..ea3b8c005 100644 --- a/docs/syntax/entityRelationshipDiagram.md +++ b/docs/syntax/entityRelationshipDiagram.md @@ -200,15 +200,15 @@ The `type` values must begin with an alphabetic character and may contain digits ### Entity Name Aliases (v\+) -An alias can be added to an entity using `as` keyword. If provided, the alias will be showed in the diagram instead of the entity name. +An alias can be added to an entity using square brackets. If provided, the alias will be showed in the diagram instead of the entity name. ```mermaid-example erDiagram - p as Person { + p[Person] { string firstName string lastName } - a as "Customer Account" { + a["Customer Account"] { string email } p ||--o| a : has @@ -216,11 +216,11 @@ erDiagram ```mermaid erDiagram - p as Person { + p[Person] { string firstName string lastName } - a as "Customer Account" { + a["Customer Account"] { string email } p ||--o| a : has diff --git a/packages/mermaid/src/diagrams/er/parser/erDiagram.jison b/packages/mermaid/src/diagrams/er/parser/erDiagram.jison index 843fd9910..ea8abc21a 100644 --- a/packages/mermaid/src/diagrams/er/parser/erDiagram.jison +++ b/packages/mermaid/src/diagrams/er/parser/erDiagram.jison @@ -35,6 +35,8 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multili [\n]+ /* nothing */ "}" { this.popState(); return 'BLOCK_STOP'; } . return yytext[0]; +"[" return 'SQS'; +"]" return 'SQE'; "one or zero" return 'ZERO_OR_ONE'; "one or more" return 'ONE_OR_MORE'; @@ -62,7 +64,6 @@ o\{ return 'ZERO_OR_MORE'; \-\- return 'IDENTIFYING'; "to" return 'IDENTIFYING'; "optionally to" return 'NON_IDENTIFYING'; -"as" return 'ALIAS'; \.\- return 'NON_IDENTIFYING'; \-\. return 'NON_IDENTIFYING'; [A-Za-z][A-Za-z0-9\-_]* return 'ALPHANUM'; @@ -114,15 +115,15 @@ statement } | entityName BLOCK_START BLOCK_STOP { yy.addEntity($1); } | entityName { yy.addEntity($1); } - | entityName ALIAS entityName BLOCK_START attributes BLOCK_STOP + | entityName SQS entityName SQE BLOCK_START attributes BLOCK_STOP { /* console.log('detected block'); */ yy.addEntity($1, $3); - yy.addAttributes($1, $5); + yy.addAttributes($1, $6); /* console.log('handled block'); */ } - | entityName ALIAS entityName BLOCK_START BLOCK_STOP { yy.addEntity($1, $3); } - | entityName ALIAS entityName { yy.addEntity($1, $3); } + | entityName SQS entityName SQE BLOCK_START BLOCK_STOP { yy.addEntity($1, $3); } + | entityName SQS entityName SQE { yy.addEntity($1, $3); } | title title_value { $$=$2.trim();yy.setAccTitle($$); } | acc_title acc_title_value { $$=$2.trim();yy.setAccTitle($$); } | acc_descr acc_descr_value { $$=$2.trim();yy.setAccDescription($$); } diff --git a/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js b/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js index c23e31876..a480e50e5 100644 --- a/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js +++ b/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js @@ -137,7 +137,7 @@ describe('when parsing ER diagram it...', function () { it('can have an alias', function () { const entity = 'foo'; const alias = 'bar'; - erDiagram.parser.parse(`erDiagram\n${entity} as "${alias}"\n`); + erDiagram.parser.parse(`erDiagram\n${entity}["${alias}"]\n`); const entities = erDb.getEntities(); expect(entities.hasOwnProperty(entity)).toBe(true); expect(entities[entity].alias).toBe(alias); diff --git a/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md b/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md index 71d91bab7..f2a5d5481 100644 --- a/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md +++ b/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md @@ -146,15 +146,15 @@ The `type` values must begin with an alphabetic character and may contain digits ### Entity Name Aliases (v+) -An alias can be added to an entity using `as` keyword. If provided, the alias will be showed in the diagram instead of the entity name. +An alias can be added to an entity using square brackets. If provided, the alias will be showed in the diagram instead of the entity name. ```mermaid-example erDiagram - p as Person { + p[Person] { string firstName string lastName } - a as "Customer Account" { + a["Customer Account"] { string email } p ||--o| a : has From fc96ebefd46f20e66ef30b4eae200d827e14d875 Mon Sep 17 00:00:00 2001 From: Reda Al Sulais Date: Tue, 22 Aug 2023 13:19:52 +0300 Subject: [PATCH 34/70] build: update `langium` and `langium-cli` to `v2.0.1` --- packages/parser/package.json | 4 ++-- pnpm-lock.yaml | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/parser/package.json b/packages/parser/package.json index e8bb1d529..caf30d492 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -34,10 +34,10 @@ "ast" ], "dependencies": { - "langium": "2.0.0" + "langium": "2.0.1" }, "devDependencies": { - "langium-cli": "2.0.0" + "langium-cli": "2.0.1" }, "files": [ "dist/" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 68cbc7351..947812fdb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -481,12 +481,12 @@ importers: packages/parser: dependencies: langium: - specifier: 2.0.0 - version: 2.0.0 + specifier: 2.0.1 + version: 2.0.1 devDependencies: langium-cli: - specifier: 2.0.0 - version: 2.0.0 + specifier: 2.0.1 + version: 2.0.1 tests/webpack: dependencies: @@ -11454,8 +11454,8 @@ packages: engines: {node: '>=12'} dev: true - /langium-cli@2.0.0: - resolution: {integrity: sha512-eyM46Hz6vQEg9bQ1ZX61OS/3ERkSaiu5YG9shmGEv3LHTltN1ziwgfL8QKbzr389QDuX7xHD1nEqUx0fOcA+Wg==} + /langium-cli@2.0.1: + resolution: {integrity: sha512-dPPaHimIoCgELED4tvRGdU3i26tjWuyVwexXgPtTtTzp1MBdGCBLppLADXHkL8yFVdWM/PWlCq06YyqAT4eV3A==} engines: {node: '>=16.0.0'} hasBin: true dependencies: @@ -11463,7 +11463,7 @@ packages: commander: 10.0.1 fs-extra: 11.1.1 jsonschema: 1.4.1 - langium: 2.0.0 + langium: 2.0.1 langium-railroad: 2.0.0 lodash: 4.17.21 dev: true @@ -11471,12 +11471,12 @@ packages: /langium-railroad@2.0.0: resolution: {integrity: sha512-g6y8vPh4i7ll/Q4D9aFrjk4UgtkuzkE6WGfiTHJHTFlDwHoiKrPSIIBZO4wjEb3XUF9P5vIt7aRjerTy7Jgm0g==} dependencies: - langium: 2.0.0 + langium: 2.0.1 railroad-diagrams: 1.0.0 dev: true - /langium@2.0.0: - resolution: {integrity: sha512-Sze9q3TIfamgXi6zkgwFylM/Wj5YmgoxvwUgYWivwKMTlBjp4j7J5AtQjuZC3QJ+/QYunIsjhj+lSR9WgxxzoQ==} + /langium@2.0.1: + resolution: {integrity: sha512-EGi8NNN/5zxcUL//sA4kqpV9YVOZfDngwkkSxsZ/zfx4Wjdg9von71rWIMCV6kW1M40kPOKF6e8oMTyWeX92fg==} engines: {node: '>=16.0.0'} dependencies: chevrotain: 11.0.3 From 8d0ca2c87604fd8cdae97799d72c6f3dba9ecf5e Mon Sep 17 00:00:00 2001 From: Reda Al Sulais Date: Tue, 22 Aug 2023 13:38:23 +0300 Subject: [PATCH 35/70] build: build `.langium` file using `generate` from `langium-cli` --- .build/generateLangium.ts | 12 +++--------- .build/langium-cli.d.ts | 9 +++++++++ .esbuild/build.ts | 2 +- .esbuild/server.ts | 4 ++-- .vite/build.ts | 2 +- package.json | 1 + pnpm-lock.yaml | 3 +++ 7 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 .build/langium-cli.d.ts diff --git a/.build/generateLangium.ts b/.build/generateLangium.ts index 7c171a11c..e37e085a5 100644 --- a/.build/generateLangium.ts +++ b/.build/generateLangium.ts @@ -1,11 +1,5 @@ -import { execFileSync } from 'child_process'; +import { generate } from 'langium-cli'; -export function generateLangium() { - execFileSync('pnpm', [ - '--prefix', - `${process.cwd()}/packages/parser`, - 'exec', - 'langium', - 'generate', - ]); +export async function generateLangium() { + await generate({ file: `./packages/parser/langium-config.json` }); } diff --git a/.build/langium-cli.d.ts b/.build/langium-cli.d.ts new file mode 100644 index 000000000..a1cfe25f8 --- /dev/null +++ b/.build/langium-cli.d.ts @@ -0,0 +1,9 @@ +declare module 'langium-cli' { + export interface GenerateOptions { + file?: string; + mode?: 'development' | 'production'; + watch?: boolean; + } + + export function generate(options: GenerateOptions): Promise; +} diff --git a/.esbuild/build.ts b/.esbuild/build.ts index 28b841341..3e829d719 100644 --- a/.esbuild/build.ts +++ b/.esbuild/build.ts @@ -53,7 +53,7 @@ const handler = (e) => { }; const main = async () => { - generateLangium(); + await generateLangium(); await mkdir('stats').catch(() => {}); const packageNames = Object.keys(packageOptions) as (keyof typeof packageOptions)[]; // it should build `parser` before `mermaid` because it's a dependecy diff --git a/.esbuild/server.ts b/.esbuild/server.ts index c522cadf8..63d981b99 100644 --- a/.esbuild/server.ts +++ b/.esbuild/server.ts @@ -79,7 +79,7 @@ function sendEventsToAll() { } async function createServer() { - generateLangium(); + await generateLangium(); handleFileChange(); const app = express(); chokidar @@ -93,7 +93,7 @@ async function createServer() { return; } if (/\.langium$/.test(path)) { - generateLangium(); + await generateLangium(); } console.log(`${path} changed. Rebuilding...`); handleFileChange(); diff --git a/.vite/build.ts b/.vite/build.ts index a97b2b5a3..9cb128eb1 100644 --- a/.vite/build.ts +++ b/.vite/build.ts @@ -114,7 +114,7 @@ const main = async () => { } }; -generateLangium(); +await generateLangium(); if (watch) { await build(getBuildConfig({ minify: false, watch, core: false, entryName: 'parser' })); diff --git a/package.json b/package.json index 0dfc09919..9e24b2aa6 100644 --- a/package.json +++ b/package.json @@ -107,6 +107,7 @@ "jison": "^0.4.18", "js-yaml": "^4.1.0", "jsdom": "^22.0.0", + "langium-cli": "2.0.1", "lint-staged": "^13.2.1", "nyc": "^15.1.0", "path-browserify": "^1.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 947812fdb..83b4f841d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -149,6 +149,9 @@ importers: jsdom: specifier: ^22.0.0 version: 22.0.0 + langium-cli: + specifier: 2.0.1 + version: 2.0.1 lint-staged: specifier: ^13.2.1 version: 13.2.1 From 4a06bc1a68ef2b425ed933989e5d29b3d80c6c47 Mon Sep 17 00:00:00 2001 From: Tom PERRILLAT-COLLOMB Date: Tue, 22 Aug 2023 13:36:25 +0200 Subject: [PATCH 36/70] test(er): add cypress test on entity name alias --- cypress/integration/rendering/erDiagram.spec.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cypress/integration/rendering/erDiagram.spec.js b/cypress/integration/rendering/erDiagram.spec.js index 28c6191c8..578f5a398 100644 --- a/cypress/integration/rendering/erDiagram.spec.js +++ b/cypress/integration/rendering/erDiagram.spec.js @@ -305,4 +305,21 @@ ORDER ||--|{ LINE-ITEM : contains {} ); }); + + it('should render entities with entity name aliases', () => { + imgSnapshotTest( + ` + erDiagram + p[Person] { + varchar(64) firstName + varchar(64) lastName + } + c["Customer Account"] { + varchar(128) email + } + p ||--o| c : has + `, + { logLevel: 1 } + ); + }); }); From 24c8e575f400343fe36f8b3030c12f07e5d56f14 Mon Sep 17 00:00:00 2001 From: Reda Al Sulais Date: Tue, 22 Aug 2023 20:39:19 +0300 Subject: [PATCH 37/70] docs(parser): create `packages/parser` README.md file --- packages/parser/README.md | 63 ++++++++++++++++++++++++++++++++++++ packages/parser/package.json | 2 +- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 packages/parser/README.md diff --git a/packages/parser/README.md b/packages/parser/README.md new file mode 100644 index 000000000..89cf67903 --- /dev/null +++ b/packages/parser/README.md @@ -0,0 +1,63 @@ +

+ + +

+

+Mermaid Parser +

+ +

+Mermaid parser package +

+ +[![NPM](https://img.shields.io/npm/v/mermaid-parser)](https://www.npmjs.com/package/mermaid-parser) + +## How the package works + +The package exports a `parse` function that has two parameters: + +```ts +declare function parse( + diagramType: keyof typeof initializers, + text: string +): T; +``` + +## How does a Langium-based parser work? + +```mermaid +sequenceDiagram +actor Package +participant Module +participant TokenBuilder +participant Lexer +participant Parser +participant ValueConverter + + +Package ->> Module: Create services +Module ->> TokenBuilder: Override or/and
reorder rules +TokenBuilder ->> Lexer: Read the string and transform
it into a token stream +Lexer ->> Parser: Parse token
stream into AST +Parser ->> ValueConverter: Clean/modify tokenized
rules returned value +ValueConverter -->> Package: Return AST +``` + +- When to override `TokenBuilder`? + + - To override keyword rules. + - To override terminal rules that need a custom function. + - To manually reorder the list of rules. + +- When to override `Lexer`? + + - To modify input before tokenizing. + - To insert/modify tokens that cannot or have not been parsed. + +- When to override `LangiumParser`? + + - To insert or modify attributes that can't be parsed. + +- When to override `ValueConverter`? + + - To modify the returned value from the parser. diff --git a/packages/parser/package.json b/packages/parser/package.json index caf30d492..68c677c8e 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -7,7 +7,7 @@ "Yokozuna59", "Sidharth Vinod (https://sidharth.dev)" ], - "homepage": "https://github.com/mermaid-js/mermaid/#readme", + "homepage": "https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/parser/#readme", "types": "dist/src/index.d.ts", "type": "module", "exports": { From cee2a458f172bd28b73cb4969d1097cb1f0a308b Mon Sep 17 00:00:00 2001 From: Nikolay Rozhkov Date: Wed, 23 Aug 2023 00:23:14 +0300 Subject: [PATCH 38/70] Fixed docs according review Update docs --- docs/community/docker-development.md | 6 +++--- docs/community/documentation.md | 7 +++---- ...uggestions.md => questions-and-suggestions.md} | 4 +--- docs/intro/index.md | 15 ++++++++++++--- packages/mermaid/src/docs/.vitepress/config.ts | 2 +- .../mermaid/src/docs/.vitepress/theme/redirect.ts | 2 +- .../src/docs/community/docker-development.md | 6 +++--- .../mermaid/src/docs/community/documentation.md | 7 +++---- ...uggestions.md => questions-and-suggestions.md} | 2 -- packages/mermaid/src/docs/intro/index.md | 15 ++++++++++++--- 10 files changed, 39 insertions(+), 27 deletions(-) rename docs/community/{questionsAndSuggestions.md => questions-and-suggestions.md} (88%) rename packages/mermaid/src/docs/community/{questionsAndSuggestions.md => questions-and-suggestions.md} (96%) diff --git a/docs/community/docker-development.md b/docs/community/docker-development.md index 4b206408c..42189a88e 100644 --- a/docs/community/docker-development.md +++ b/docs/community/docker-development.md @@ -34,14 +34,14 @@ Then you **clone** a copy to your local development machine (e.g. where you code [Install Docker](https://docs.docker.com/engine/install/). And that is pretty much all you need. -Optionally, to run GUI (Cypress) within Docker you will also need X11 server installed. -Maybe you already have it installed, so check it first: +Optionally, to run GUI (Cypress) within Docker you will also need an X11 server installed. +You might already have it installed, so check this by running: ```bash echo $DISPLAY ``` -If variable `$DISPLAY` is not empty, then it must be working. Otherwise install it. +If the `$DISPLAY` variable is not empty, then an X11 server is running. Otherwise you may need to install one. ## Setup and Launch diff --git a/docs/community/documentation.md b/docs/community/documentation.md index b4f19597a..67d35d395 100644 --- a/docs/community/documentation.md +++ b/docs/community/documentation.md @@ -42,7 +42,7 @@ flowchart LR You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box. Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly. -```` +````markdown ```note Note content ``` @@ -58,11 +58,10 @@ Warning content ```danger Danger content ``` - ```` > **Note** -> If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. +> If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. In that case, your branch should be based on master, not develop. We encourage contributions to the documentation at [packages/mermaid/src/docs in the _develop_ branch](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs). @@ -87,7 +86,7 @@ _\[TODO: need to keep this in sync with [check out a git branch in Contributing 2. Find the Markdown file (.md) to edit in the `packages/mermaid/src/docs` directory. 3. Make changes or add new documentation. 4. Commit changes to your branch and push it to GitHub (which should create a new branch). -5. Create a Pull Request of your fork. +5. Create a Pull Request from the branch of your fork. To edit Docs on GitHub: diff --git a/docs/community/questionsAndSuggestions.md b/docs/community/questions-and-suggestions.md similarity index 88% rename from docs/community/questionsAndSuggestions.md rename to docs/community/questions-and-suggestions.md index 28b107d1f..23d6de50f 100644 --- a/docs/community/questionsAndSuggestions.md +++ b/docs/community/questions-and-suggestions.md @@ -2,7 +2,7 @@ > > ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. > -> ## Please edit the corresponding file in [/packages/mermaid/src/docs/community/questionsAndSuggestions.md](../../packages/mermaid/src/docs/community/questionsAndSuggestions.md). +> ## Please edit the corresponding file in [/packages/mermaid/src/docs/community/questions-and-suggestions.md](../../packages/mermaid/src/docs/community/questions-and-suggestions.md). # Questions or Suggestions? @@ -24,5 +24,3 @@ Feel free to add to the discussion on the issue or topic. If you can't find anything that already addresses your question or suggestion, _open a new issue:_ Log in to [GitHub.com](https://www.github.com), open or append to an issue [using the GitHub issue tracker of the mermaid-js repository](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Documentation%22). - -## How to Contribute a Suggestion diff --git a/docs/intro/index.md b/docs/intro/index.md index b77dd454f..0197d7950 100644 --- a/docs/intro/index.md +++ b/docs/intro/index.md @@ -16,7 +16,14 @@ It is a JavaScript based diagramming and charting tool that renders Markdown-ins

-[![Build CI Status](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml/badge.svg)](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) [![NPM](https://img.shields.io/npm/v/mermaid)](https://www.npmjs.com/package/mermaid) [![npm minified gzipped bundle size](https://img.shields.io/bundlephobia/minzip/mermaid)](https://bundlephobia.com/package/mermaid) [![Coverage Status](https://coveralls.io/repos/github/mermaid-js/mermaid/badge.svg?branch=master)](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [![CDN Status](https://img.shields.io/jsdelivr/npm/hm/mermaid)](https://www.jsdelivr.com/package/npm/mermaid) [![NPM](https://img.shields.io/npm/dm/mermaid)](https://www.npmjs.com/package/mermaid) [![Join our Slack!](https://img.shields.io/static/v1?message=join%20chat&color=9cf&logo=slack&label=slack)](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) [![Twitter Follow](https://img.shields.io/twitter/follow/mermaidjs_?style=social)](https://twitter.com/mermaidjs_) +[![Build CI Status](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml/badge.svg)](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) +[![NPM](https://img.shields.io/npm/v/mermaid)](https://www.npmjs.com/package/mermaid) +[![npm minified gzipped bundle size](https://img.shields.io/bundlephobia/minzip/mermaid)](https://bundlephobia.com/package/mermaid) +[![Coverage Status](https://coveralls.io/repos/github/mermaid-js/mermaid/badge.svg?branch=master)](https://coveralls.io/github/mermaid-js/mermaid?branch=master) +[![CDN Status](https://img.shields.io/jsdelivr/npm/hm/mermaid)](https://www.jsdelivr.com/package/npm/mermaid) +[![NPM](https://img.shields.io/npm/dm/mermaid)](https://www.npmjs.com/package/mermaid) +[![Join our Slack!](https://img.shields.io/static/v1?message=join%20chat&color=9cf&logo=slack&label=slack)](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) +[![Twitter Follow](https://img.shields.io/twitter/follow/mermaidjs_?style=social)](https://twitter.com/mermaidjs_)
@@ -322,7 +329,6 @@ To Deploy Mermaid: - [Mermaid CLI](https://github.com/mermaid-js/mermaid-cli) - [Mermaid Webpack Demo](https://github.com/mermaidjs/mermaid-webpack-demo) - [Mermaid Parcel Demo](https://github.com/mermaidjs/mermaid-parcel-demo) -- [HTTP Server](https://github.com/TomWright/mermaid-server) ## Request for Assistance @@ -343,7 +349,9 @@ Don't hesitate to contact me if you want to get involved!
-[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) [![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) [![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) +[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) +[![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) +[![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors)
@@ -428,6 +436,7 @@ _Mermaid was created by Knut Sveidqvist for easier documentation._ .badges > p { display: flex; } + .badges > p > a { margin: 0 0.5rem; } diff --git a/packages/mermaid/src/docs/.vitepress/config.ts b/packages/mermaid/src/docs/.vitepress/config.ts index f86da0490..d787fe6ea 100644 --- a/packages/mermaid/src/docs/.vitepress/config.ts +++ b/packages/mermaid/src/docs/.vitepress/config.ts @@ -196,7 +196,7 @@ function sidebarCommunity() { { text: 'Contributing to Mermaid', link: '/community/development' }, { text: 'Contributing Code', link: '/community/code' }, { text: 'Contributing Documentation', link: '/community/documentation' }, - { text: 'Questions and Suggestions', link: '/community/questionsAndSuggestions' }, + { text: 'Questions and Suggestions', link: '/community/questions-and-suggestions' }, { text: 'Adding Diagrams', link: '/community/newDiagram' }, { text: 'Security', link: '/community/security' }, ], diff --git a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts index da4326be7..951ee5371 100644 --- a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts +++ b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts @@ -49,7 +49,7 @@ const idRedirectMap: Record = { 'more-pages': '', 'n00b-advanced': 'config/n00b-advanced', 'n00b-gettingstarted': 'intro/n00b-gettingStarted', - 'n00b-overview': 'community/n00b-overview', + 'n00b-overview': 'intro/n00b-gettingStarted', 'community/n00b-overview': 'intro/n00b-gettingStarted', 'n00b-syntaxreference': 'intro/n00b-syntaxReference', newdiagram: 'community/newDiagram', diff --git a/packages/mermaid/src/docs/community/docker-development.md b/packages/mermaid/src/docs/community/docker-development.md index f3fb41391..33cd6a201 100644 --- a/packages/mermaid/src/docs/community/docker-development.md +++ b/packages/mermaid/src/docs/community/docker-development.md @@ -28,14 +28,14 @@ Then you **clone** a copy to your local development machine (e.g. where you code [Install Docker](https://docs.docker.com/engine/install/). And that is pretty much all you need. -Optionally, to run GUI (Cypress) within Docker you will also need X11 server installed. -Maybe you already have it installed, so check it first: +Optionally, to run GUI (Cypress) within Docker you will also need an X11 server installed. +You might already have it installed, so check this by running: ```bash echo $DISPLAY ``` -If variable `$DISPLAY` is not empty, then it must be working. Otherwise install it. +If the `$DISPLAY` variable is not empty, then an X11 server is running. Otherwise you may need to install one. ## Setup and Launch diff --git a/packages/mermaid/src/docs/community/documentation.md b/packages/mermaid/src/docs/community/documentation.md index 79a984376..6a0df983d 100644 --- a/packages/mermaid/src/docs/community/documentation.md +++ b/packages/mermaid/src/docs/community/documentation.md @@ -28,7 +28,7 @@ flowchart LR You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box. Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly. -```` +````markdown ```note Note content ``` @@ -44,11 +44,10 @@ Warning content ```danger Danger content ``` - ```` ```note -If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. +If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. In that case, your branch should be based on master, not develop. ``` We encourage contributions to the documentation at [packages/mermaid/src/docs in the _develop_ branch](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs). @@ -74,7 +73,7 @@ _[TODO: need to keep this in sync with [check out a git branch in Contributing C 2. Find the Markdown file (.md) to edit in the `packages/mermaid/src/docs` directory. 3. Make changes or add new documentation. 4. Commit changes to your branch and push it to GitHub (which should create a new branch). -5. Create a Pull Request of your fork. +5. Create a Pull Request from the branch of your fork. To edit Docs on GitHub: diff --git a/packages/mermaid/src/docs/community/questionsAndSuggestions.md b/packages/mermaid/src/docs/community/questions-and-suggestions.md similarity index 96% rename from packages/mermaid/src/docs/community/questionsAndSuggestions.md rename to packages/mermaid/src/docs/community/questions-and-suggestions.md index f72d0a47d..6d6f80fb6 100644 --- a/packages/mermaid/src/docs/community/questionsAndSuggestions.md +++ b/packages/mermaid/src/docs/community/questions-and-suggestions.md @@ -18,5 +18,3 @@ Feel free to add to the discussion on the issue or topic. If you can't find anything that already addresses your question or suggestion, _open a new issue:_ Log in to [GitHub.com](https://www.github.com), open or append to an issue [using the GitHub issue tracker of the mermaid-js repository](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Documentation%22). - -## How to Contribute a Suggestion diff --git a/packages/mermaid/src/docs/intro/index.md b/packages/mermaid/src/docs/intro/index.md index c76f09a08..8410ef1cb 100644 --- a/packages/mermaid/src/docs/intro/index.md +++ b/packages/mermaid/src/docs/intro/index.md @@ -10,7 +10,14 @@ It is a JavaScript based diagramming and charting tool that renders Markdown-ins
-[![Build CI Status](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml/badge.svg)](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) [![NPM](https://img.shields.io/npm/v/mermaid)](https://www.npmjs.com/package/mermaid) [![npm minified gzipped bundle size](https://img.shields.io/bundlephobia/minzip/mermaid)](https://bundlephobia.com/package/mermaid) [![Coverage Status](https://coveralls.io/repos/github/mermaid-js/mermaid/badge.svg?branch=master)](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [![CDN Status](https://img.shields.io/jsdelivr/npm/hm/mermaid)](https://www.jsdelivr.com/package/npm/mermaid) [![NPM](https://img.shields.io/npm/dm/mermaid)](https://www.npmjs.com/package/mermaid) [![Join our Slack!](https://img.shields.io/static/v1?message=join%20chat&color=9cf&logo=slack&label=slack)](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) [![Twitter Follow](https://img.shields.io/twitter/follow/mermaidjs_?style=social)](https://twitter.com/mermaidjs_) +[![Build CI Status](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml/badge.svg)](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) +[![NPM](https://img.shields.io/npm/v/mermaid)](https://www.npmjs.com/package/mermaid) +[![npm minified gzipped bundle size](https://img.shields.io/bundlephobia/minzip/mermaid)](https://bundlephobia.com/package/mermaid) +[![Coverage Status](https://coveralls.io/repos/github/mermaid-js/mermaid/badge.svg?branch=master)](https://coveralls.io/github/mermaid-js/mermaid?branch=master) +[![CDN Status](https://img.shields.io/jsdelivr/npm/hm/mermaid)](https://www.jsdelivr.com/package/npm/mermaid) +[![NPM](https://img.shields.io/npm/dm/mermaid)](https://www.npmjs.com/package/mermaid) +[![Join our Slack!](https://img.shields.io/static/v1?message=join%20chat&color=9cf&logo=slack&label=slack)](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) +[![Twitter Follow](https://img.shields.io/twitter/follow/mermaidjs_?style=social)](https://twitter.com/mermaidjs_)
@@ -99,7 +106,6 @@ To Deploy Mermaid: - [Mermaid CLI](https://github.com/mermaid-js/mermaid-cli) - [Mermaid Webpack Demo](https://github.com/mermaidjs/mermaid-webpack-demo) - [Mermaid Parcel Demo](https://github.com/mermaidjs/mermaid-parcel-demo) -- [HTTP Server](https://github.com/TomWright/mermaid-server) ## Request for Assistance @@ -120,7 +126,9 @@ Don't hesitate to contact me if you want to get involved!
-[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) [![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) [![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) +[![Good first issue](https://img.shields.io/github/labels/mermaid-js/mermaid/Good%20first%20issue%21)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22) +[![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) +[![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors)
@@ -205,6 +213,7 @@ _Mermaid was created by Knut Sveidqvist for easier documentation._ .badges > p { display: flex; } + .badges > p > a { margin: 0 0.5rem; } From 108c25f19f72fad9f3e20551435439b18aac9267 Mon Sep 17 00:00:00 2001 From: Nikolay Rozhkov Date: Wed, 23 Aug 2023 23:32:33 +0300 Subject: [PATCH 39/70] Removed all n00b file names and added redirects --- docker-compose.yml | 2 +- packages/mermaid/src/docs/.vitepress/config.ts | 6 +++--- .../src/docs/.vitepress/theme/redirect.spec.ts | 4 ++-- .../mermaid/src/docs/.vitepress/theme/redirect.ts | 15 +++++++++------ packages/mermaid/src/docs/config/Tutorials.md | 2 +- .../docs/config/{n00b-advanced.md => advanced.md} | 2 +- packages/mermaid/src/docs/config/usage.md | 2 +- ...{n00b-gettingStarted.md => getting-started.md} | 4 ++-- packages/mermaid/src/docs/intro/index.md | 8 ++++---- ...00b-syntaxReference.md => syntax-reference.md} | 6 +++--- pnpm-lock.yaml | 2 +- 11 files changed, 28 insertions(+), 25 deletions(-) rename packages/mermaid/src/docs/config/{n00b-advanced.md => advanced.md} (90%) rename packages/mermaid/src/docs/intro/{n00b-gettingStarted.md => getting-started.md} (96%) rename packages/mermaid/src/docs/intro/{n00b-syntaxReference.md => syntax-reference.md} (95%) diff --git a/docker-compose.yml b/docker-compose.yml index 2480311a2..5ee31964d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: working_dir: /mermaid mem_limit: '2G' environment: - - NODE_OPTIONS=--max_old_space_size=2048 + - NODE_OPTIONS=--max_old_space_size=4096 volumes: - ./:/mermaid - root_cache:/root/.cache diff --git a/packages/mermaid/src/docs/.vitepress/config.ts b/packages/mermaid/src/docs/.vitepress/config.ts index d787fe6ea..ede064fa4 100644 --- a/packages/mermaid/src/docs/.vitepress/config.ts +++ b/packages/mermaid/src/docs/.vitepress/config.ts @@ -109,8 +109,8 @@ function sidebarAll() { collapsed: false, items: [ { text: 'About Mermaid', link: '/intro/' }, - { text: 'Getting Started', link: '/intro/n00b-gettingStarted' }, - { text: 'Syntax and Configuration', link: '/intro/n00b-syntaxReference' }, + { text: 'Getting Started', link: '/intro/getting-started' }, + { text: 'Syntax and Configuration', link: '/intro/syntax-reference' }, ], }, ...sidebarSyntax(), @@ -167,7 +167,7 @@ function sidebarConfig() { { text: 'Theming', link: '/config/theming' }, { text: 'Accessibility', link: '/config/accessibility' }, { text: 'Mermaid CLI', link: '/config/mermaidCLI' }, - { text: 'Advanced usage', link: '/config/n00b-advanced' }, + { text: 'Advanced usage', link: '/config/advanced' }, { text: 'FAQ', link: '/config/faq' }, ], }, diff --git a/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts b/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts index 3d88913d1..b78f63990 100644 --- a/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts +++ b/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts @@ -19,8 +19,8 @@ test.each([ 'https://mermaid-js.github.io/mermaid/#/flowchart?another=test&id=my-id&one=more', // with multiple params 'syntax/flowchart.html#my-id', ], - ['https://mermaid-js.github.io/mermaid/#/n00b-advanced', 'config/n00b-advanced.html'], // without .md - ['https://mermaid-js.github.io/mermaid/#/n00b-advanced.md', 'config/n00b-advanced.html'], // with .md + ['https://mermaid-js.github.io/mermaid/#/n00b-advanced', 'config/advanced.html'], // without .md + ['https://mermaid-js.github.io/mermaid/#/n00b-advanced.md', 'config/advanced.html'], // with .md [ 'https://mermaid-js.github.io/mermaid/#/flowchart?id=a-node-in-the-form-of-a-circle', // with id, without .md 'syntax/flowchart.html#a-node-in-the-form-of-a-circle', diff --git a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts index 8d576fece..98009ca6d 100644 --- a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts +++ b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts @@ -50,15 +50,18 @@ const idRedirectMap: Record = { mermaidcli: 'config/mermaidCLI', mindmap: 'syntax/mindmap', 'more-pages': '', - 'n00b-advanced': 'config/n00b-advanced', - 'n00b-gettingstarted': 'intro/n00b-gettingStarted', - 'n00b-overview': 'intro/n00b-gettingStarted', - 'community/n00b-overview': 'intro/n00b-gettingStarted', - 'n00b-syntaxreference': 'intro/n00b-syntaxReference', + 'n00b-advanced': 'config/advanced', + 'config/n00b-advanced': 'config/advanced', + 'n00b-gettingstarted': 'intro/getting-started', + 'intro/n00b-gettingStarted': 'intro/getting-started', + 'n00b-overview': 'intro/getting-started', + 'n00b-syntaxreference': 'intro/syntax-reference', + 'intro/n00b-syntaxReference': 'intro/syntax-reference', + 'community/n00b-overview': 'intro/getting-started', newdiagram: 'community/newDiagram', pie: 'syntax/pie', plugins: '', - quickstart: 'intro/n00b-gettingStarted', + quickstart: 'intro/getting-started', requirementdiagram: 'syntax/requirementDiagram', security: 'community/security', sequencediagram: 'syntax/sequenceDiagram', diff --git a/packages/mermaid/src/docs/config/Tutorials.md b/packages/mermaid/src/docs/config/Tutorials.md index c6db9dacf..af7dbe672 100644 --- a/packages/mermaid/src/docs/config/Tutorials.md +++ b/packages/mermaid/src/docs/config/Tutorials.md @@ -26,7 +26,7 @@ The definitions that can be generated the Live-Editor are also backwards-compati ## Mermaid with HTML -Examples are provided in [Getting Started](../intro/n00b-gettingStarted.md) +Examples are provided in [Getting Started](../intro/getting-started.md) **CodePen Examples:** diff --git a/packages/mermaid/src/docs/config/n00b-advanced.md b/packages/mermaid/src/docs/config/advanced.md similarity index 90% rename from packages/mermaid/src/docs/config/n00b-advanced.md rename to packages/mermaid/src/docs/config/advanced.md index 2932faa48..4ab477428 100644 --- a/packages/mermaid/src/docs/config/n00b-advanced.md +++ b/packages/mermaid/src/docs/config/advanced.md @@ -1,4 +1,4 @@ -# Advanced n00b mermaid (Coming soon..) +# Advanced mermaid (Coming soon..) ## splitting mermaid code from html diff --git a/packages/mermaid/src/docs/config/usage.md b/packages/mermaid/src/docs/config/usage.md index 740b3509b..7f3a04caa 100644 --- a/packages/mermaid/src/docs/config/usage.md +++ b/packages/mermaid/src/docs/config/usage.md @@ -35,7 +35,7 @@ pnpm add mermaid **Hosting mermaid on a web page:** -> Note:This topic explored in greater depth in the [User Guide for Beginners](../intro/n00b-gettingStarted.md) +> Note:This topic explored in greater depth in the [User Guide for Beginners](../intro/getting-started.md) The easiest way to integrate mermaid on a web page requires two elements: diff --git a/packages/mermaid/src/docs/intro/n00b-gettingStarted.md b/packages/mermaid/src/docs/intro/getting-started.md similarity index 96% rename from packages/mermaid/src/docs/intro/n00b-gettingStarted.md rename to packages/mermaid/src/docs/intro/getting-started.md index fcb3f31ee..47ffa7291 100644 --- a/packages/mermaid/src/docs/intro/n00b-gettingStarted.md +++ b/packages/mermaid/src/docs/intro/getting-started.md @@ -2,7 +2,7 @@ Mermaid is composed of three parts: Deployment, Syntax and Configuration. -This section talks about the different ways to deploy Mermaid. Learning the [Syntax](n00b-syntaxReference.md) would be of great help to the beginner. +This section talks about the different ways to deploy Mermaid. Learning the [Syntax](syntax-reference.md) would be of great help to the beginner. > Generally the live editor is enough for most general uses of mermaid, and is a good place to start learning. @@ -36,7 +36,7 @@ graph TD In the `Code` section one can write or edit raw mermaid code, and instantly `Preview` the rendered result on the panel beside it. -The `Configuration` Section is for changing the appearance and behavior of mermaid diagrams. An easy introduction to mermaid configuration is found in the [Advanced usage](../config/n00b-advanced.md) section. A complete configuration reference cataloging the default values can be found on the [mermaidAPI](../config/setup/README.md) page. +The `Configuration` Section is for changing the appearance and behavior of mermaid diagrams. An easy introduction to mermaid configuration is found in the [Advanced usage](../config/advanced.md) section. A complete configuration reference cataloging the default values can be found on the [mermaidAPI](../config/setup/README.md) page. ![Code,Config and Preview](./img/Code-Preview-Config.png) diff --git a/packages/mermaid/src/docs/intro/index.md b/packages/mermaid/src/docs/intro/index.md index 8410ef1cb..554db5a12 100644 --- a/packages/mermaid/src/docs/intro/index.md +++ b/packages/mermaid/src/docs/intro/index.md @@ -4,7 +4,7 @@ It is a JavaScript based diagramming and charting tool that renders Markdown-inspired text definitions to create and modify diagrams dynamically. -> If you are familiar with Markdown you should have no problem learning [Mermaid's Syntax](n00b-syntaxReference.md). +> If you are familiar with Markdown you should have no problem learning [Mermaid's Syntax](syntax-reference.md). @@ -39,7 +39,7 @@ Mermaid allows even non-programmers to easily create detailed and diagrams throu [Tutorials](../config/Tutorials.md) has video tutorials. Use Mermaid with your favorite applications, check out the list of [Integrations and Usages of Mermaid](../ecosystem/integrations.md). -For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](../intro/n00b-gettingStarted.md) and [Usage](../config/usage.md). +For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](../intro/getting-started.md) and [Usage](../config/usage.md). 🌐 [CDN](https://www.jsdelivr.com/package/npm/mermaid) | 📖 [Documentation](https://mermaidjs.github.io) | 🙌 [Contribution](../community/development.md) | 🔌 [Plug-Ins](../ecosystem/integrations.md) @@ -59,9 +59,9 @@ In our release process we rely heavily on visual regression tests using [applito ## Installation -**In depth guides and examples can be found at [Getting Started](./n00b-gettingStarted.md) and [Usage](../config/usage.md).** +**In depth guides and examples can be found at [Getting Started](./getting-started.md) and [Usage](../config/usage.md).** -**It would also be helpful to learn more about mermaid's [Syntax](./n00b-syntaxReference.md).** +**It would also be helpful to learn more about mermaid's [Syntax](./syntax-reference.md).** ### CDN diff --git a/packages/mermaid/src/docs/intro/n00b-syntaxReference.md b/packages/mermaid/src/docs/intro/syntax-reference.md similarity index 95% rename from packages/mermaid/src/docs/intro/n00b-syntaxReference.md rename to packages/mermaid/src/docs/intro/syntax-reference.md index 398f83257..51f25be35 100644 --- a/packages/mermaid/src/docs/intro/n00b-syntaxReference.md +++ b/packages/mermaid/src/docs/intro/syntax-reference.md @@ -24,7 +24,7 @@ erDiagram PRODUCT ||--o{ ORDER-ITEM : "ordered in" ``` -The [Getting Started](./n00b-gettingStarted.md) section can also provide some practical examples of mermaid syntax. +The [Getting Started](./getting-started.md) section can also provide some practical examples of mermaid syntax. ## Diagram Breaking @@ -48,13 +48,13 @@ Configuration is the third part of Mermaid, after deployment and syntax. It deal If you are interested in altering and customizing your Mermaid Diagrams, you will find the methods and values available for [Configuration](../config/setup/README.md) here. It includes themes. This section will introduce the different methods of configuring the behaviors and appearances of Mermaid Diagrams. -The following are the most commonly used methods, and they are all tied to Mermaid [Deployment](./n00b-gettingStarted.md) methods. +The following are the most commonly used methods, and they are all tied to Mermaid [Deployment](./getting-started.md) methods. ### Configuration Section in the [Live Editor](https://mermaid.live). Here you can edit certain values to change the behavior and appearance of the diagram. -### [The initialize() call](https://mermaid-js.github.io/mermaid/#/n00b-gettingStarted?id=_3-calling-the-javascript-api), +### [The initialize() call](https://mermaid-js.github.io/mermaid/#/getting-started?id=_3-calling-the-javascript-api), Used when Mermaid is called via an API, or through a `