Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Previewing Mermaid Diagrams #952

Open
1eyewonder opened this issue Feb 7, 2025 · 4 comments
Open

Add Support for Previewing Mermaid Diagrams #952

1eyewonder opened this issue Feb 7, 2025 · 4 comments

Comments

@1eyewonder
Copy link
Contributor

Summary

I wanted to open this issue in order to start a discussion for potentially adding support for previewing mermaid diagrams using FsDocs. I think this would be a great addition to the tooling so users/developers can stay within the bounds of fsdocs and navigate any visualizations created by the mermaid syntax.

Applicable Areas

There are the areas I see as being applicable if we wanted to pursue this functionality

  1. Literate scripts
  2. Markdown docs

Areas of Inspiration

The reason I point to these is these two sites have a much better user experience in terms of panning and zooming. While GitHub has a built in previewer, in my opinion, their panning and zooming is not ideals for larger mermaid diagrams.

  1. https://mermaid.live/
  2. https://github.com/newmo-oss/mermaid-viewer
@nojaf
Copy link
Collaborator

nojaf commented Feb 7, 2025

I've used this in the past.
In _body.html add

<script type="module">
    import mermaid from "https://esm.sh/[email protected]";
    mermaid.initialize({
        startOnLoad: true,
        theme: "base",
        themeVariables: {
            primaryColor: '#ffdd59'
        }
    });
</script>

and then use in Markdown:

<div class="mermaid text-center">
graph TD
    D[Teplin.Core]
    E[Telplin]
    F[Telplin.Lambda]
    G[Telplin.Core.Tests]
    D --> E
    D --> F
    D --> G
    H[Telplin.Deploy]
    I[OnlineTool]
 </div>

It makes me wonder if this should be an out of the box thing or not.
Perhaps adding this recipe to the docs is good enough to start out.

@nhirschey
Copy link
Collaborator

I like @nojaf’s idea. A docs recipe like the latex MathJax one could be nice https://fsprojects.github.io/FSharp.Formatting/sidebyside/sideextensions.html

@1eyewonder
Copy link
Contributor Author

I can add this to my docs to-do list. Thanks for the code snippet!

@houstonhaynes
Copy link

Has anyone checked out Siren as an option? https://github.com/Freymaurer/Siren

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants