NAME

App::Greple::md::Mermaid - draw the Mermaid diagrams of a Markdown text

SYNOPSIS

use App::Greple::md::Mermaid qw(diagram_files);

my @png = diagram_files(codes => \@codes, theme => 'dark');

DESCRIPTION

This module draws the Mermaid diagrams for the mermaid type of the image_types option of App::Greple::md, which shows them with Text::ANSI::Image.

diagram_files(codes => [CODE, ...], command => COMMAND, theme => THEME, background => COLOR, scale => N)

Returns the PNG files of the diagrams, in the order of the codes, and undef for one that could not be drawn. They are drawn by COMMAND (split into words as a shell does; default mmdr of mermaid-rs-renderer), into mdee-mermaid-UID of the temporary directory (TMPDIR, or /tmp), a directory only the user can read, and are drawn again only when the code, the command or the theme, the background (default transparent) or the scale (default 1.5) changes, or when the file is gone: the files are left for the system to clean up. Nothing is drawn when that directory is a symbolic link or belongs to someone else. Diagrams drawn before are shown even when the directory cannot be written.

Each diagram is drawn in a run of its own. mmdr has no options for the background and the scale: the background is given as themeVariables in a file of -c, unless COMMAND has its own -c (--configFile), and for a scale other than 1 it is first asked for the size of the diagram (--size) and then given that size multiplied (-w, -H), unless COMMAND has a width or a height of its own.

A diagram that cannot be drawn is not shown, and is tried again the next time.

SEE ALSO

App::Greple::md, Text::ANSI::Image

LICENSE

This software is released under the MIT License. https://opensource.org/licenses/MIT