Skip to content

Mermaid diagrams: document how to escape conflicting syntax #2550

Description

@damithc

Some Mermaid diagram syntax conflict with MarkBind syntax. For example, the following Git graph code.

<mermaid>
%%{init: { 'logLevel': 'debug', 'theme': 'base', 'gitGraph': {'rotateCommitLabel': true}} }%%
gitGraph
  commit id: "feat(api): ..."
  commit id: "a"
  commit id: "b"
  commit id: "fix(client): .extra long label.."
  branch c2
  commit id: "feat(modules): ..."
  commit id: "test(client): ..."
  checkout main
  commit id: "fix(api): ..."
  commit id: "ci: ..."
  branch b1
  commit
  branch b2
  commit
</mermaid>
%%{init: { 'logLevel': 'debug', 'theme': 'base', 'gitGraph': {'rotateCommitLabel': true}} }%%
gitGraph
  commit id: "feat(api): ..."
  commit id: "a"
  commit id: "b"
  commit id: "fix(client): .extra long label.."
  branch c2
  commit id: "feat(modules): ..."
  commit id: "test(client): ..."
  checkout main
  commit id: "fix(api): ..."
  commit id: "ci: ..."
  branch b1
  commit
  branch b2
  commit
Loading

The workaround is to escape the conflicting part using {{ "..." }}, as follows.

<mermaid>
{{ "%%{init: { 'logLevel': 'debug', 'theme': 'base', 'gitGraph': {'rotateCommitLabel': true}} }%%" }}
gitGraph
  commit id: "feat(api): ..."
  commit id: "a"
 ..
</mermaid>

Suggestion: Perhaps this can be mentioned as a tip in the documentation, specifically when explaining how to use Mermaid diagrams?

Activity

  1. nightcityblade commented on Jul 30, 2026

    @nightcityblade
    Contributor

    Hi, I'd like to work on this. I'll submit a PR shortly.

  2. Incogdino commented on Aug 3, 2026

    @Incogdino
    Contributor
  3. allcontributors commented on Aug 3, 2026

    @allcontributors
    Contributor

    @Incogdino

    I've put up a pull request to add @nightcityblade! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions