Mermaid CLI icon

Mermaid CLI

Execute Mermaid CLI commands for diagram generation

Batch Process

AI-generated

Overview

This node operation performs batch processing of Mermaid diagram files located in a specified input directory. It matches files based on a given pattern (e.g., *.mmd), processes each file to generate diagrams in a chosen output format (SVG, PNG, or PDF), and saves the results to an output directory. It supports parallel processing with a configurable maximum number of concurrent processes, improving efficiency when handling multiple files. This operation is useful for automating the conversion of multiple Mermaid diagram files into visual formats in bulk, such as generating documentation diagrams or visual reports from Mermaid source files.

Use Case Examples

  1. A user has a directory of Mermaid files (*.mmd) representing different flowcharts and wants to convert all of them to SVG format and save them in another directory automatically.
  2. A team needs to generate PNG images from a batch of Mermaid diagrams stored in a folder, processing up to 4 files concurrently to speed up the workflow.

Properties

Name Meaning
Input Directory Directory containing Mermaid files to process.
File Pattern File pattern to match Mermaid files for processing (e.g., *.mmd, *.mermaid).
Output Directory Directory where the processed diagram files will be saved.
Output Format Format to generate the output diagrams in (SVG, PNG, or PDF).
Parallel Processing Whether to process files in parallel to improve speed.
Max Concurrent Maximum number of concurrent processes when parallel processing is enabled.

Output

JSON

  • success - Indicates if the batch processing was successful.
  • filesProcessed - Total number of files matched and processed.
  • successful - Number of files processed successfully.
  • failed - Number of files that failed processing.
  • parallel - Indicates if parallel processing was used.
  • maxConcurrent - Maximum number of concurrent processes used (if parallel processing enabled).
  • results - Array of results for each processed file, including file name, success status, input and output paths, and error messages if any.

Dependencies

  • Mermaid CLI executable (mmdc) must be available in the environment, typically requiring Puppeteer and Chromium browser dependencies.

Troubleshooting

  • Common issues include invalid input directory or file pattern resulting in no files found to process.
  • Errors during Mermaid CLI execution for individual files may occur due to malformed Mermaid syntax or environment setup issues.
  • If parallel processing is enabled, system resource limits may cause failures; reducing max concurrent processes can help.
  • Error messages from Mermaid CLI execution failures are propagated and should be checked for details to resolve issues.

Links

Discussion