Discourse Mermaid

AI-generated summary

The Discourse Mermaid theme component allows users to create powerful graphs using Mermaid syntax. It is an official theme component maintained by the Discourse team, with support, bug reports, UX discussions, and feature requests directed to specific categories on Meta Discourse.

Usage and Features
Users can embed diagrams using the ```mermaid block. The component renders SVG HTML elements rather than static images, although graphs do not render in emails. The default error message guides users to ensure their code is valid and indented correctly.

Community Discussions and Issues

  • Font Awesome Icons: 37 cmdntd reported that FontAwesome icons do not display correctly when used in Mermaid syntax, despite working in the live editor. Arkshine noted that a feature request has been created to address this.
  • SVG vs PNG: katzuv asked about generating SVGs instead of PNGs. Arkshine clarified that the component renders SVG HTML elements by default.
  • Styling and Scaling: putty inquired about mimicking the “rough” style from the Mermaid previewer. volas reported strange scaling issues and zooming problems in Firefox, which worked better in Chrome. volas also noted that Mermaid places error messages at the end of the <body> tag, a behavior confirmed by Tris20 who finds it non-breaking but poor UX.
  • Click Events: Stephen reported that click events within diagrams create links in the source but do not function.
  • Version Updates: whitewaterdeu and pacharanero discussed the supported Mermaid version. pacharanero expressed interest in the new Wardley Mapping chart type and offered to submit a Pull Request (PR) to update the underlying library. Falco welcomed the PR, which was subsequently submitted by pacharanero.
:discourse2: Summary Discourse Mermaid lets you create very powerful graphs using the Mermaid syntax.
:eyeglasses: Preview Preview on Discourse Theme Creator
:hammer_and_wrench: Repository Link https://github.com/discourse/discourse-mermaid-theme-component
:open_book: New to Discourse Themes? Beginner’s guide to using Discourse Themes

Install this theme component

Usage

```mermaid height=200
graph TD;
  A --> B;
```

Learn more about the Mermaid syntax on the official website: Mermaid | Diagramming and charting tool

:warning: Graphs won’t be rendered in emails

Settings

Name Description
svg icons
Translation Default
rendering_error

<b>Error</b><p>Please ensure your mermaid code is running on <a href=‘https://mermaid.live/’>mermaid.live and indented with 4 spaces, eg: <pre><code> flowchart TB
A → B</code></pre></p>

insert_mermaid_sample Mermaid chart

:discourse2: Hosted by us? Theme components are available to use on our Pro, Business and Enterprise plans.

Last edited by @Moin 2026-04-22T16:48:24Z

Check documentPerform check on document:
31 Likes

Chart does not display icon when you use fontawesome:

I failed when I tesed with this:

flowchart LR
    A>fas:fa-plane-departure Airline] -->|11/04/2024| B

But it is ok if you test here:

A feature request has been posted here:

3 Likes

3 posts were split to a new topic: Upgrade Mermaid to 10.6.1

Is it possible to generate an SVG instead of PNG?

Hi, welcome :wave:

This doesn’t generate an image. It renders an SVG HTML element. If you refer to the example in the first post, it is meant to be a screenshot of the result. I understand it might be confusing. You can see a live example below:

graph TD;
  A --> B;
3 Likes

2 posts were merged into an existing topic: Scaling issue for charts

Hi there,
Don’t suppose there is a way to mimic the “rough” style that can be found in the Mermaid previewer (top right):
CleanShot 2025-03-04 at 14.11.16

I’m guessing it’s a slim chance since the code doesn’t actually change, but worth a shot!

2 Likes

Scaling works strange in Firefox, and I can’t zoom in the chart with large height.

How it looks in the post:

Post screenshot

How it looks when expanded (click does nothing, but if chart is LR then I can click for zooming):

Expanded screenshot

Mermaid chart from the example:

Chart
flowchart TD
    A["Lorem ipsum dolor"] --> B["Sit amet consectetur"]
    A --> C["Adipiscing elit sed"]
    B --> E["Do eiusmod tempor"]
    C --> D["Incididunt ut labore"]
    D --> F["Et dolore magna"]
    E --> G["Aliqua ut enim"]
    F --> G
    G --> H["Ad minim veniam"]
    H --> I["Quis nostrud exercitation"]
    C --> J["Ullamco laboris nisi"]
    I --> K["Ut aliquip ex"]
    J --> L["Ea commodo consequat"]
    L --> M["Duis aute irure"]
    M --> N["Dolor in reprehenderit"]
    N --> O["In voluptate velit"]
    K --> P["Esse cillum dolore"]
    P --> Q["Eu fugiat nulla"]
    Q --> R["Pariatur excepteur sint"]
    L --> S["Occaecat cupidatat non"]
    F --> T["Proident sunt in"]
    S --> U["Culpa qui officia"]
    U --> V["Deserunt mollit anim"]
    R --> W["Id est laborum"]
    W --> X["Sed ut perspiciatis"]
    O --> Y["Unde omnis iste"]
    X --> Z["Natus error sit"]
    Z --> AA["Voluptatem accusantium doloremque"]
    AA --> AB["Laudantium totam rem"]
    AB --> AC["Aperiam eaque ipsa"]
    AC --> AD["Quae ab illo"]
    T --> Y
    V --> Q
    D --> M
    E --> R

In chrome it works better.

Mermaid also places errors at the end of the <body> tag of discourse

1 Like

post was originally written in Русский

Huh. It was in English except the image name. Thanks, discourse.

What i actually wrote:

Mermaid also places errors at the end of the <body> tag of discourse

I get this as well after submitting changes, but if I refresh my page the error goes away. IMO not something which breaks functionality, but definitely undermines the otherwise great experience.

Is click currently supported within mermaid diagrams?

flowchart TD
   start --> relative
   relative --> absolute
   absolute --> external

   click relative "/categories" "tooltip1"
   click absolute "https://meta.discourse.org/docs" "tooltip2"
   click external "https://github.com/" "tooltip3"

I can see the link being created in the page source, but they aren’t working.

Which mermaid version is supported by this component?

2 Likes

What is the typical cadence for updates of Discourse Mermaid, as regards the underlying mermaid.js library? I ask because from 11.14 onwards there is a new Wardley Mapping chart type included (in beta), which is of significant interest to my communities.

At the time of writing the latest version is 11.15.0, and reportedly the Wardley feature is now acceptably stable.

If a PR would be accepted I am happy to bash one out!

2 Likes

A pr is indeed welcome!

3 Likes
3 Likes