Using Mermaid in MediaWiki: Difference between revisions

From Freephile Wiki
fix syntaxhighlight (there is no highlighter for mermaid.js)
m Tagged
Line 169: Line 169:
[[Category:Sales]]
[[Category:Sales]]
[[Category:Company]]
[[Category:Company]]
[[Category:Diagrams]]

Revision as of 13:50, 16 June 2025

On the Sales Cycle page, we briefly compare two diagramming extensions for MediaWiki: Mermaid vs Flex Diagrams.

While Flex Diagrams allows you to create 5 types of diagrams - including all those available through Mermaid, the limitation that you can not combine wiki markup in the 'sandboxed' implementation of Flex Diagrams makes us prefer creating Mermaid diagrams using the Mermaid extension.

The Mermaid.js library is capable of generating all these types of diagrams.

  1. Flowchart
  2. Sequence Diagram
  3. Class Diagram
  4. State Diagram
  5. Entity Relationship Diagram
  6. User Journey
  7. Gantt
  8. Pie Chart
  9. Quadrant Chart
  10. Requirement Diagram
  11. Gitgraph (Git) Diagram
  12. C4 Diagram 🦺⚠️
  13. Mindmaps
  14. Timeline
  15. ZenUML
  16. Sankey 🔥
  17. XY Chart 🔥
  18. Block Diagram 🔥
  19. Packet 🔥
  20. Kanban 🔥
  21. Architecture 🔥
  22. Radar 🔥

Building Diagrams[edit]

Use the Mermaid Live Editor (javascript in-browser editor for Mermaid markup @ mermaid.live)

There are a ton of integrations for editing the Mermaid script language in your content platform or editor of choice. For example, there's an extension for VSCode to interact with Mermaid. See https://mermaid.js.org/ecosystem/integrations-community.html for the full rundown.

Docs[edit]

  1. Syntax Reference

Mermaid Extension for MediaWiki[edit]

  1. MediaWiki extension page https://www.mediawiki.org/wiki/Extension:Mermaid

Repo[edit]

  1. MediaWiki extension repo on GitHub https://github.com/SemanticMediaWiki/Mermaid

Examples[edit]

In addition to the examples below, the Semantic MediaWiki (sandbox) website shows some examples of Mermaid markup plus the MediaWiki parser function:

  • Mermaid - gantt chart
  • Mermaid - graph
  • Mermaid - graph with links
  • Mermaid - graph with links and tooltips
  • Mermaid - sequence diagram
  • Mermaid - subgraph
  • Mermaid - wide graph (CSS hack to fix horizontal scrolling)

GANNT Chart[edit]

{{#mermaid:gantt
	title A Gantt Diagram
	dateFormat  YYYY-MM-DD
	section Section
	A task           :a1, 2014-01-01, 30d
	Another task     :after a1  , 20d
	section Another
	Task in sec      :2014-01-12  , 12d
	another task      : 24d
}}

produces

Flow Chart[edit]

{{#mermaid:graph TD
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[fa:fa-car Car]
}}

produces

Sequence Diagram[edit]

{{#mermaid:sequenceDiagram
	Alice->>+John: Hello John, how are you?
	Alice->>+John: John, can you hear me?
	John-->>-Alice: Hi Alice, I can hear you!
	John-->>-Alice: I feel great!
}}

produces

Class Diagram[edit]

{{#mermaid:classDiagram
	Animal <|-- Duck
	Animal <|-- Fish
	Animal <|-- Zebra
	Animal : +int age
	Animal : +String gender
	Animal: +isMammal()
	Animal: +mate()
	class Duck{
		+String beakColor
		+swim()
		+quack()
	}
	class Fish{
		-int sizeInFeet
		-canEat()
	}
	class Zebra{
		+bool is_wild
		+run()
	}
}}

produces

References[edit]