Dhgms.DocFx.MermaidJs.Plugin
5.0.61
dotnet add package Dhgms.DocFx.MermaidJs.Plugin --version 5.0.61
NuGet\Install-Package Dhgms.DocFx.MermaidJs.Plugin -Version 5.0.61
<PackageReference Include="Dhgms.DocFx.MermaidJs.Plugin" Version="5.0.61" />
<PackageVersion Include="Dhgms.DocFx.MermaidJs.Plugin" Version="5.0.61" />
<PackageReference Include="Dhgms.DocFx.MermaidJs.Plugin" />
paket add Dhgms.DocFx.MermaidJs.Plugin --version 5.0.61
#r "nuget: Dhgms.DocFx.MermaidJs.Plugin, 5.0.61"
#:package Dhgms.DocFx.MermaidJs.Plugin@5.0.61
#addin nuget:?package=Dhgms.DocFx.MermaidJs.Plugin&version=5.0.61
#tool nuget:?package=Dhgms.DocFx.MermaidJs.Plugin&version=5.0.61
DocFx MermaidJS
Mission Statement
To provide a plugin to convert MermaidJS notations to diagrams during the build of a DocFX project.
Introduction
This DocFX MermaidJS plugin is a wrapper around the mermaid NPM package. It is aimed at doing build time generation of the mermaid diagram so:
- The syntax can be validated at build time.
- The image is only built once.
- The image can be embedded in a pdf.
- You can work on custom docfx templates that minimise javascript and\ or packages.
NOTES:
- Only inline PNG is supported, this is due to a limitation in the plug in model and adding new files to the file cache on the fly. I may revisit this in future. The plug in itself exposes SVG data if you want to play with it.
- This package was originally written around the DFM flavor of Markdown in DocFX. With that now unsupported in DocFX you can in theory just use
Whipstaff.Mermaidwhich this package now effectively acts as a wrapper to.
Credits
- https://dotnet.github.io/docfx/
- https://mermaid.js.org/
- https://github.com/mermaid-js/mermaid-cli
- https://github.com/mermaid-js/mermaid
- https://github.com/dpvreony/article-statiq-mermaid
- https://github.com/KevReed/DocFx.Plugins.PlantUml
Getting Started
1. Create a console application (or similar)
2. Add a nuget package reference to "Dhgms.DocFX.Mermaid.Plugin" in your docfx_project
3. Add the following initialisation
using (var loggerFactory = new Microsoft.Extensions.Logging.Abstractions.NullLoggerFactory())
{
var playwrightRenderer = PlaywrightRenderer.Default(loggerFactory);
var browserSession = await playwrightRenderer.GetBrowserSessionAsync(PlaywrightBrowserTypeAndChannel.Chrome())
.ConfigureAwait(false);
var markdownJsExtensionSettings = new MarkdownJsExtensionSettings(
browserSession,
OutputMode.Svg);
var options = new BuildOptions
{
// Enable MermaidJS markdown extension
ConfigureMarkdig = pipeline => pipeline.UseMermaidJsExtension(
markdownJsExtensionSettings,
loggerFactory)
};
await Docset.Build("docfx.json", options);
}
You can see an example of this in
- The sample console application in this repository (github.com/dpvreony/docfx-mermaidjs/tree/main/src/Dhgms.DocFx.MermaidJs.Sample.Cmd)
- The console application in my main documentation repository (github.com/dpvreony/documentation/tree/main/src/docfx_project)
You can adjust the settings by viewing the detailed documentation.
4. Adding a diagram
In your markdown files add a code block with a mermaid descriptor like so:
```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```
Then you can run the build and you should see the image output in place of the mermaid markdown syntax.
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
Viewing the documentation
The documentation can be found at https://docs.dpvreony.com/projects/docfx-mermaidjs/
Contributing to the code
See the contribution guidelines.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Docfx.MarkdigEngine.Extensions (>= 2.78.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.10)
- Nito.AsyncEx (>= 5.1.2)
- System.Reactive (>= 6.1.0)
- Whipstaff.Markdig (>= 9.1.205)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.0.61 | 62 | 7/15/2026 |
| 5.0.44 | 215 | 5/21/2026 |
| 4.0.25 | 545 | 8/26/2025 |
| 4.0.1 | 393 | 6/17/2025 |
| 3.0.163 | 374 | 5/21/2025 |
| 3.0.1 | 3,757 | 4/17/2024 |
| 2.0.71 | 373 | 3/25/2024 |
| 2.0.62 | 426 | 3/7/2024 |
| 2.0.33 | 466 | 1/15/2024 |
| 2.0.30 | 320 | 1/12/2024 |
| 2.0.2 | 505 | 11/29/2023 |
| 2.0.1 | 295 | 11/28/2023 |
| 1.0.410 | 383 | 11/6/2023 |
| 1.0.386 | 342 | 10/20/2023 |
| 1.0.366 | 388 | 10/2/2023 |
| 1.0.315 | 614 | 8/26/2023 |
| 1.0.291 | 377 | 8/14/2023 |
| 1.0.275 | 368 | 8/4/2023 |
| 1.0.250 | 401 | 6/30/2023 |
| 1.0.224 | 424 | 6/12/2023 |