Pele  

Plugin to render mermaid diagrams at build time using Pele

Description

This plugin render mermaid diagrams using Pele. You only need to wrap the source code in an element with the pele class. For example:

<div class="pele">
flowchart TD
  A[Mermaid text] --> B{Flowchart?}
  B -- Yes --> C[Pele]
  B -- No --> D[Mermaid]
  C --> E([SVG])
  D --> E
</div>

The plugin will replace the source code with the rendered diagram in SVG:

<div class="pele">
  <svg>...</svg>
</div>

Note

For code blocks in markdown, the <pre><code> elements are replaced with the SVG.

Installation

Import this plugin in your _config.ts file to use it:

import lume from "@lumeland/lume";
import pele from "@lumeland/plugin-pele";

const site = lume();

site.use(pele(/* Options */));

export default site;

Typography

At build time, Pele uses the hard-coded metrics of the font Arial to calculate the text dimmensions and it's not possible to use a custom font with different dimmensions.

To mitigate this limitation, this plugin provides the monospace option to configure Pele to calculate the text dimmensions to use a monospace font, which makes everything easier due all characters have the same width:

site.use(pele({
  monospace: true,
}));

Now you only have to configure Pele to use your favorite monospace font in the CSS file:

.pele {
  --pele-font: "JetBrains Mono", monospace;
}

By default, the monospace mode set a value of 0.6 per character (the font size 1em would have a width of 0.6em). You can configure a different ratio:

site.use(pele({
  monospace: 0.7,
}));

Note

Go to Pele documentation for a list of all available CSS properties to customize the styles