Programmatically adding Mermaid diagrams
Developers can write scripts to programmatically add macros and attachments with Mermaid diagrams.
Adding a macro
In order to display the Mermaid diagram on a Confluence page, page needs to be parsed and mermaidcloud macro added to it.
Macro parameters:
Parameter name | Description | Mandatory |
---|---|---|
filename | Name of the diagram text attachment | Yes |
revision | Latest version of SVG attachment, in this case it is 1 | Yes |
toolbar | bottom or none | No |
Diagram text attachment
Mermaid diagram text is stored in the plain text attachment on a Confluence page. The add-on will load the text from it when viewing or editing the macro.
PNG diagram export
The add-on relies on PNG exports for showing diagrams in PDF page exports.
PNG exports must be saved as Confluence attachments on a page where the diagram resides. Naming must follow diagram naming. For diagram titled My FSM diagram, the PNG export would be called My FSM diagram.png.
Mermaid library outputs an SVG image. This image can be converted into PNG using instructions found on this link How to convert a SVG to PNG using Canvas