DEV Community

Cover image for ✨ Mermaid Markdown: Adding Life and Creativity to your GitHub Markdown Files 👩‍💻🌈📄
Sergio Marcial
Sergio Marcial

Posted on

✨ Mermaid Markdown: Adding Life and Creativity to your GitHub Markdown Files 👩‍💻🌈📄

Introduction 🚀

As engineers, we often find ourselves documenting our code, ideas, and processes using Markdown files, whether it's READMEs, project documentation, or collaborative notes. Markdown is a simple and widely adopted markup language for creating easy-to-read and aesthetically pleasing files. However, it lacks the ability to visualize complex data structures or create dynamic diagrams. This is where Mermaid Markdown comes to the rescue!

What is Mermaid Markdown? 🧜‍♀️

Mermaid Markdown is an innovative extension to standard Markdown that allows you to include visually appealing diagrams, flowcharts, and sequence diagrams in your Markdown files. By integrating Mermaid Markdown into your workflow, you can bring life and interactivity to your documentation, making it easier for readers to understand complex ideas and visualize data flows.

What problem does Mermaid Markdown aim to solve? 🎯

Traditional Markdown feels limiting when it comes to expressing complex concepts and relationships. When we want to demonstrate the interaction between different components in a system or visualize a sequence of events, we often resort to external tools or screenshots. This can be time-consuming and doesn't provide the same ease of collaboration as Markdown itself.

With Mermaid Markdown, you can create diagrams directly within your Markdown files using a simple, human-readable syntax. This allows you to document processes, architectures, and data flows seamlessly, without leaving your Markdown file.

Enriching your Markdown in GitHub with Mermaid Markdown 🌟

Adding Mermaid Markdown support to your GitHub repositories is a breeze! Follow these steps to get started:

Install a Markdown editor with Mermaid support 📝

  • VSCode: Install the "Markdown Preview Mermaid Support" extension.
  • IntelliJ: Install the "Mermaid" plugin.
  • Other editors: Look for similar extensions or packages specific to your editor.

Include Mermaid Markdown in your Markdown file 🖊️

Use the following code snippet to add a Mermaid diagram to your Markdown file:

Examples:

Flowchart:

graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
Enter fullscreen mode Exit fullscreen mode

Image description

Gantt Chart:

gantt
    dateFormat  YYYY-MM-DD
    title Adding Mermaid Diagrams
    section A section
    task Task 1: 2023-09-01, 7d
    task Task 2: 2023-09-08, 5d
    task Task 3: 2023-09-15, 6d
    section Another section
    task Task 4: 2023-09-01, 8d
    task Task 5: 2023-09-11, 5d
    task Task 6: 2023-09-20, 6d
Enter fullscreen mode Exit fullscreen mode

Image description

Class Diagram:

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 isWild
        +run()
    }
Enter fullscreen mode Exit fullscreen mode

Image description

You can replace this example with your own diagram using Mermaid's extensive syntax.

Preview your Markdown locally ✨

Enable the Mermaid Markdown preview in your editor and visualize how the diagram renders alongside your Markdown content. This allows you to make any necessary adjustments before committing the changes to your repository.

Commit and push your changes to GitHub 🚀

Once you're happy with your Mermaid Markdown diagram, commit your changes and push them to GitHub. Your diagrams will be rendered on your repository's GitHub page, dynamically enhancing your documentation and making it more engaging for readers.

Conclusion 📝

Mermaid Markdown empowers engineers at all levels to add interactivity and visual creativity to their Markdown files, elevating the quality and comprehensibility of technical documentation. By integrating Mermaid Markdown into your GitHub repositories, you can effectively showcase system architectures, visualize data flows, and create captivating diagrams.

Don't let the simplicity of Markdown restrict your documentation's potential. Embrace Mermaid Markdown today and give your diagrams the spotlight they deserve! 🎉

🔗 Additional reading:

Happy Markdown diagramming! 🚀🎨📄

Top comments (1)

Collapse
 
fredlag profile image
fredlag

Thanks for the share mermaid js is a very good tool.