# merman-cli [![Crates.io](https://img.shields.io/crates/v/merman-cli.svg)](https://crates.io/crates/merman-cli) [![Documentation](https://docs.rs/merman-cli/badge.svg)](https://docs.rs/merman-cli) [![License](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-59636e.svg)](https://github.com/Latias94/merman/blob/main/LICENSE-MIT) Render, inspect, and lint Mermaid without Node.js, Puppeteer, Chromium, or another JavaScript runtime. The source-default binary includes all diagram families, SVG, outlined SVG (`--svg-outlines`), DrawList v1 JSON (`--format draw-list-json`), PNG, JPEG, vector PDF, ASCII/Unicode, Theme v2, Shoal/Dagre/ELK/Cytoscape layouts, analysis/fixes, Markdown batch rendering, local icons, completions, `platform-system-font-default`, `rustdoc`, and native runtime adapters. Official release archives (`cli-release`) additionally select `math` and `network-icons` explicitly. Source defaults omit `math` and `network-icons`; pass `--features math` and/or `--features network-icons` to include them. Both default and release builds include ELK, with its EPL-2.0 notices and source provenance; explicit lean builds can omit it. The commands in this guide target the current source checkout. Use `merman-cli --version` and `merman-cli capabilities --json` to check your installed binary. The [changelog](https://github.com/Latias94/merman/blob/main/CHANGELOG.md) covers upgrades and the [host guide](https://github.com/Latias94/merman/blob/main/docs/release/PREBUILT_PRODUCTS.md) lists available versions and installation channels. ## Choose an output | Use case | Command | | --- | --- | | Browser SVG with Mermaid HTML labels | `merman-cli render diagram.mmd` | | SVG for viewers without the original fonts | `merman-cli render diagram.mmd --svg-outlines` | | SVG for resvg/usvg or fixed markup | `merman-cli render diagram.mmd --svg-pipeline resvg-safe` (defaults to `Static` generation). Use `--svg-pipeline static` for fixed browser markup. | | Renderer-neutral DrawList v1 JSON (`flowchart`, `sequence`, `class`, `state`, `er`) | `merman-cli render diagram.mmd --format draw-list-json` (add `--draw-list-expand-markers` to bake endpoint markers into paths) | | PNG, JPEG, or vector PDF | `merman-cli render diagram.mmd --format png`. Use `--format jpg` or `--format pdf` for the other formats. | | Mermaid fences in Markdown | `merman-cli batch README.md` or `merman-cli mmdc -i README.md -o rendered.md` for mmdc compatibility | | Terminal ASCII, Unicode, or ANSI color | `merman-cli render diagram.mmd --format ascii -o -`. Use `--format unicode --ascii-color ansi16` for colored Unicode. | Use `--layout shoal` (and optional `--fit-width --width 720`) to select the bundled [Shoal layout engine](https://github.com/Latias94/merman/blob/main/docs/rendering/SHOAL_LAYOUT.md). For native exports (`--svg-outlines`, `resvg-safe`, PNG, JPEG, PDF, or `draw-list-json`) containing unavailable formulas, pass `--native-math-fallback strict|source-text|drop` (defaults to `strict`). See the [DrawList v1 guide](https://github.com/Latias94/merman/blob/main/docs/rendering/DRAW_LIST.md) for schema and compact-admission rules. Raw SVG input requires a compiled PNG, JPEG, or PDF encoder and one of those output formats. In encoder-enabled builds, `render` infers SVG from `.svg` filenames. Use `--input-kind svg` for SVG on stdin or `--input-kind mermaid` to override the filename. ## Install Install the CLI from crates.io: ```sh cargo install merman-cli --version 0.12.0 --locked ``` Install the matching prebuilt archive with cargo-binstall: ```sh cargo binstall merman-cli@0.12.0 ``` Merman's cargo-binstall metadata uses the repository's cargo-dist archive, disables third-party QuickInstall artifacts, and retains `cargo install` as a fallback when an official archive is unavailable. Check `merman-cli --version` before relying on the API or output schema in this guide. Homebrew users can install the stable formula: ```sh brew install merman-cli ``` The formula follows its own stable release schedule; check its installed version against the host guide. Windows users can install from Scoop's main bucket: ```powershell scoop install merman-cli ``` External package managers update on their own schedule. Check the installed version against the [host guide](https://github.com/Latias94/merman/blob/main/docs/release/PREBUILT_PRODUCTS.md). Starting with `0.8.0-alpha.5`, version-specific [GitHub Releases](https://github.com/Latias94/merman/releases) also provide `merman-cli-installer.sh` and `merman-cli-installer.ps1`. Download an installer from the chosen release rather than a moving URL; it installs only the binary and fails closed if the archive SHA-256 cannot be verified. From the matching reviewed source checkout: ```sh cargo install --path crates/merman-cli --locked ``` The source default includes ELK; alpha.6 source defaults omitted it. Project release artifacts select the complete `cli-release` capability set, including ELK, and ship the matching notices. Cargo-dist and, beginning with `0.8.0-alpha.5`, cargo-binstall consume the project-built `dist` artifact; source channels build the default features unless you select an explicit profile. Channels also differ in which support files they place on disk and who publishes them: | Channel | Binary source | Completion and man pages | Availability | | --- | --- | --- | --- | | `cargo binstall merman-cli@VERSION` | `0.8.0-alpha.5` and later: project release archive, with source fallback | Not installed | Selected registry version; its own metadata governs | | GitHub shell or PowerShell installer | Project release archive | Not installed | `0.8.0-alpha.5` and later | | Direct GitHub archive | Project release archive | Bundled under `completions/` and `man/` | `0.8.0-alpha.5` and later | | Homebrew formula | Formula source build or Homebrew bottle | Controlled by the selected formula; inspect its support-asset installation | External stable channel; selected formula version governs | | Repository Nix package | Built from locked repository source | Bash, Zsh, Fish, PowerShell, Elvish, and man pages installed | First-party source interface, not a registry package | | `cargo install` | Built from crates.io, Git, or a checkout | Not installed | Registry or source revision selected by the user | | Scoop and WinGet | Verified Windows x86_64 release archive | Not installed | Upstream manifests govern availability; see the [host guide](https://github.com/Latias94/merman/blob/main/docs/release/PREBUILT_PRODUCTS.md) | Nix users can run `nix run . -- --version` or `nix profile install .` from a checkout at the exact accepted preflight commit. This source package is separate from the precompiled Linux archive compatibility claim. Older cargo-binstall releases follow the metadata and fallback policy embedded in that selected release; the current official-archive mapping and QuickInstall prohibition do not apply retroactively. A complete binary, or a custom build that includes `shell-completions`, can generate completion at runtime: ```sh merman-cli completion bash merman-cli completion zsh merman-cli completion fish merman-cli completion powershell merman-cli completion elvish ``` Release archives beginning with `0.8.0-alpha.5` also include legal notices. Cargo-binstall installs only the executable. The cargo-dist installers likewise omit completion and man files, but may create an environment file and update shell startup configuration to expose their install directory on `PATH`. Direct archive users should verify the adjacent checksum and the GitHub attestation constrained to the release workflow and tag; the [CLI release contract](https://github.com/Latias94/merman/blob/main/docs/release/CLI.md) provides the exact command and trust boundary. The repository also provides an [Arch source package recipe](https://github.com/Latias94/merman/blob/main/distribution/arch/README.md), a [GitHub Actions setup action](https://github.com/Latias94/merman/blob/main/distribution/github-action/README.md), and a [container build and publishing workflow](https://github.com/Latias94/merman/blob/main/distribution/container/README.md). AUR, GHCR, and Marketplace availability are separate from these repository integrations. The setup action requires an exact CLI version and a separately pinned action commit. GNU Linux compatibility depends on the selected release: current GNU Linux release archives are built and verified on Ubuntu 24.04 against a **GLIBC 2.39** baseline (Ubuntu 24.04+, Debian 13+, and modern Linux distributions). Published older archives retain their original baseline (for example, `0.9.0` requires GLIBC 2.38). See the [Linux release contract](https://github.com/Latias94/merman/blob/main/docs/release/CLI.md#gnu-linux-compatibility). The executable is named `merman-cli`; Merman does not install an `mmdc` alias. ## First Render For a named input, native rendering writes a sibling file and replaces the source extension: ```sh merman-cli render diagram.mmd # writes diagram.svg merman-cli render diagram.mmd --format png # writes diagram.png ``` Piped input writes the payload to stdout: ```sh printf 'flowchart LR\n Source --> Merman --> SVG\n' | merman-cli render - ``` Use `--output -` to request stdout explicitly or `--output PATH` to choose a file. Payload bytes go only to stdout; diagnostics and progress go to stderr. ## Common Workflows Mermaid SVG output uses deterministic text measurement without system-font discovery. Mermaid PNG/JPEG/PDF output uses native measurement by default when the CLI includes `system-fonts`, sharing a font context between layout and painting. For reproducible font selection, [provide fixed local fonts](#explicit-fonts). | Task | Command | | --- | --- | | Build committed Rustdoc fragments | `merman-cli rustdoc build` | | Verify committed Rustdoc fragments | `merman-cli rustdoc check --quiet` | | Human-readable diagnostics | `merman-cli lint diagram.mmd` | | Machine-readable diagnostics | `merman-cli lint diagram.mmd --format json` | | Check whether fixes are needed | `merman-cli fix diagram.mmd --check` | | Inspect the compiled binary | `merman-cli capabilities --json` | Run `merman-cli --help` to see only the commands compiled into your binary, then use ` --help` for command-owned options. Use an explicit `render --format` when the destination has a custom suffix, for example `merman-cli render diagram.mmd --format svg --output diagram.svg.tmp`. A recognized suffix must match the selected format. For binary PNG, JPEG, or PDF output, choose a file with `--output` or send stdout to a pipe or redirection. Native SVG rendering leaves the canvas background unset, matching Mermaid core. Use `render --background white` for an opaque SVG canvas or choose another explicit color. The `mmdc` compatibility command defaults to white and accepts `--backgroundColor transparent` for host compositing. PNG/PDF backgrounds are applied by export options independently of SVG CSS. For a coding-agent or log channel, choose explicit width and Plain report output. Given a Flowchart or Sequence input in a build with Auto support: ```sh merman-cli render diagram.mmd --format unicode --ascii-layout-profile auto --ascii-max-width 80 --ascii-overflow fallback --ascii-color plain --ascii-report --output - ``` The caller owns terminal detection, pager actions, caching, and display of returned artifacts. The CLI owns command-line I/O and its documented color-auto policy; those behaviors are not implicit library behavior. For embedded integrations, use the [host integration recipes](https://github.com/Latias94/merman/blob/main/crates/merman/examples/README.md#host-integration-recipes). `lint` defaults to stable human-readable text. Automation should request `--format json` explicitly; `lint-rules` remains JSON by default, and `--pretty` is valid only with JSON output. ### Shoal Preview Frames Editor integrations can opt into placement hints for successive SVG renders of the same Mermaid diagram. Check `capabilities --json` for `preview_layout_frame.protocol_version` equal to `1` and use its `max_bytes` limit. ```sh merman-cli render diagram.mmd --output - --preview-frame-out first.json merman-cli render diagram.mmd --output - --preview-frame-in first.json --preview-frame-out next.json ``` Each option is optional. Use an existing frame JSON file of up to 4 MiB for input and a new path for output. Malformed frame JSON stops the render with an input error. The CLI writes a separate frame file after a successful SVG render that produces an in-limit Shoal frame. The SVG payload keeps its ordinary format. ## Explicit Fonts Current-source default builds and the official release profile include `native-fonts` and `system-fonts`. Mermaid SVG keeps deterministic, font-agnostic measurement by default. Cargo defaults and the release profile query system fonts through DirectWrite on Windows, Core Text on macOS, and Fontconfig on Linux for Mermaid PNG/JPEG/PDF. Measurement and painting share the selected fonts. Font selection can change wrapping, node sizes, and image/PDF output across hosts or discovery providers. With those CLI capabilities compiled: | Font options | Mermaid SVG measurement | Mermaid PNG/JPEG/PDF measurement | Native-context system discovery | | --- | --- | --- | --- | | No font options | Deterministic | Native | Default provider for PNG/JPEG/PDF; off for SVG | | `--font-measurement deterministic` | Deterministic | Deterministic | Off | | `--font-file PATH` or `--font-dir PATH` | Native, using supplied fonts | Native, using supplied fonts | Off unless system fallback is requested | | `--font-measurement native` without font sources | Native | Native | On | | `--font-system on` | Native | Native | Explicitly on | To retain the previous font-agnostic layout estimates and native painting for an encoded output, select deterministic measurement explicitly: ```sh merman-cli render diagram.mmd --format png --font-measurement deterministic ``` That compatibility route can still discover system fonts during painting; it does not guarantee font-free or host-independent PNG/JPEG/PDF bytes. The same output-based defaults apply to Mermaid input through `render`, `batch`, and `mmdc`. Raw SVG conversion only paints existing geometry and is never relaid out. Builds with `system-fonts` use their default provider for raw SVG PNG, JPEG, and PDF. A font source or system provider option selects the conversion font context explicitly. `--font-max-bytes` applies the byte budget to the selected provider. The CLI checks the finalized SVG for text, including text inside nested `` elements, before it starts system discovery. Path-only SVG can be converted with `--font-system off` and no font files. Supply explicit fonts to paint text with system discovery off. For diagrams with strict layout requirements, **provide the fonts that will be used to display the result**. Actual-font measurement uses their glyph sizes for labels, wrapping and node layout; fixed files also avoid full system-font catalogue discovery. The CLI does not bundle diagram text fonts. Set Mermaid's `fontFamily` to the family stored in your files. For example, `diagram.mmd` can select your local Fira Sans fonts: ```mermaid --- config: fontFamily: "Fira Sans" --- flowchart LR A[Prepare diagram] --> B[Measure text and render] ``` ```sh # SVG with explicit regular and bold font files. merman-cli render diagram.mmd --output diagram.svg --font-file fonts/FiraSans-Regular.ttf --font-file fonts/FiraSans-Bold.ttf # PNG with fonts from a local directory; write output outside that directory. merman-cli render diagram.mmd --format png --output diagram.png --font-dir fonts ``` Supply the regular, bold or italic files your diagram uses. Sources are repeatable and earlier equal family/style/weight faces take precedence. Explicit sources form a closed set, even with `--font-measurement native`. To allow system fallback, add `--font-system on` or choose an available provider explicitly. Fixed font contents and matching configuration make layout more reproducible. Directories with many fonts can take longer to scan. To explicitly use the fonts installed on the current machine instead: ```sh merman-cli render diagram.mmd --output diagram.svg --font-measurement native ``` Both default Cargo source builds and official `cli-release` archives enable `platform-system-font-default`, offering `--font-system platform` and `--font-system bounded`. `--font-system on` uses the build's default provider (Platform). On Linux, the default and `on` retry with bounded discovery if the Fontconfig runtime cannot load. An explicit `platform` request reports the load error. An available service with an empty catalog and font budget failures are reported directly. Platform metadata queries run outside Merman's scan budgets. For a missing shaping cluster, platform fallback tries the authored font stack, then the supplied fonts, then the platform's candidates. Measurement and painting use the same physical face and effective variation coordinates for the cluster. Font selection honors SVG `xml:lang`, including inherited tags and `` overrides. On Windows, DirectWrite's fallback scale applies to both layout and painting. See [Optional CLI fonts](https://github.com/Latias94/merman/blob/main/docs/FEATURES.md#optional-cli-fonts). If bounded discovery reports `native font limit system-cmap-bytes exceeded`, the installed fonts' combined character map tables exceeded the bounded scan budget (64 MiB by default). Supply the diagram's fonts with `--font-file` / `--font-dir` (and `--font-system off`), or select `--font-system platform` on a build that offers it. The font data budget covers explicit font files (including files from `--font-dir`) and selected system font data combined. On macOS, `trusted-native` and `unbounded-for-trusted-input` with system font discovery enabled default to 384 MiB to accommodate CJK and emoji fallback. Other configurations, including `constrained`, default to 256 MiB. Use `--font-max-bytes ` to replace that default with a positive integer in bytes, KiB, MiB, or GiB. For example, `--font-max-bytes 536870912` and `--font-max-bytes 512MiB` set the same limit. Native Mermaid SVG requires an active native font context to use this budget. Select native measurement or supply a font with `--font-file` or `--font-dir`. For compatibility, `mmdc` accepts the budget with its default deterministic SVG output, where the budget has no effect. For raw SVG conversion, a byte budget on its own selects the build's default system provider. If the fonts exceed the budget, the CLI preserves the existing output file. Retry the same command with the `--font-max-bytes` argument from stderr, replacing any previous value. Native measurement allows 16,384 uncached shaping probes per diagram by default. Large diagrams can reach this budget because one label may need several probes. If the CLI reports `native_font_measurements`, simplify or split the diagram, or retain your font options and increase the finite budget: ```sh merman-cli render diagram.mmd --output diagram.svg --font-file fonts/FiraSans-Regular.ttf --font-max-measurements 32768 ``` The reported `actual` is the first rejected probe, not the total needed to finish. `--resource-profile` does not change this font-provider limit. The same option is available on `mmdc` and `batch`; each diagram gets its own allowance. It requires native Mermaid measurement and does not apply to raw SVG conversion. See the [host resource guide](https://github.com/Latias94/merman/blob/main/docs/integrations/RESOURCE_POLICY.md#native-font-measurement-budget) for the corresponding Rust API. Explicit font files added roughly 2–7 ms per invocation in two small Windows Flowchart SVG probes: about 43–46 ms with default measurement and 46–53 ms with fixed fonts, using warm filesystem caches. These observations do not predict large-diagram or PNG/JPEG/PDF latency. System-font discovery can add much more work; supply the fonts used by your document when precise wrapping and node bounds matter. See the [native font runtime measurements](https://github.com/Latias94/merman/blob/main/docs/performance/native_font_runtime_2026-11-22.md). `render` and `batch` accept `--font-family FAMILY` to set Mermaid's site `fontFamily`. Diagram frontmatter can override it. This option selects among available faces without supplying a font file or changing the measurement policy. Automatic native measurement for encoded output falls back to deterministic measurement when the diagram uses a CSS file, nonempty `themeCSS`, or unsupported text geometry styles. The selected native fonts still paint the output. The CLI explains the fallback on stderr unless `--quiet` is set. Explicit `--font-measurement native`, `--font-file`, or `--font-dir` keeps strict native measurement. Use `--font-measurement deterministic` without font sources to select compatibility layout explicitly. CSS security admission still applies. Minimal builds without the CLI `system-fonts` capability keep deterministic encoded-output defaults and require explicit sources for native measurement. Dependency feature union alone does not enable the CLI policy. If a native route cannot load any usable fonts, it fails instead of silently succeeding with deterministic estimates. Unsupported individual probes and missing glyphs retain their documented per-request fallback. Rust library, bindings, ASCII, and committed Rustdoc generation defaults are unchanged. Explicit font directories and system discovery roots may be symlinks, including `~/.fonts` links into a dotfiles checkout. Root and ancestor aliases are resolved before scanning; symlinks encountered inside a directory are still skipped. Explicit font files and directories are protected inputs. With `--font-dir`, choose output outside that directory; existing output files with multiple hard links are rejected because an alias to a directory font cannot be excluded without scanning the directory again. New outputs and ordinary existing outputs remain supported, including when the Mermaid source lives in the font directory. Native measurement uses the shared text-measurement infrastructure for layout, wrapping, SVG bounds, and computed lengths, not just titles. SVG output does not embed fonts; viewers need the same fonts. Raw SVG conversion uses supplied fonts for painting only and cannot relayout existing geometry. See [font support and limitations](https://github.com/Latias94/merman/blob/main/docs/FEATURES.md#optional-cli-fonts). Deterministic layout can size a fixed HTML label viewport more narrowly than the font used by PNG/PDF painting. For example, Mindmap labels can clip even when the outer node has padding. The native encoded-output default shares layout and painting metrics; explicit fonts also make the selected faces reproducible. Supply every face needed by bold, italic, and mixed labels. A successful native export with unresolved fonts or glyphs reports a warning with the actual missing resolution state and `.notdef` glyph count. If text is missing, select a family that covers it or pass `--font-file PATH` for each required font. `--quiet` suppresses that diagnostic. Best-effort export remains permissive, while strict portability admission retains its existing rejection policy. Native export reports fidelity warnings for directional filter offsets under transforms that mix the filter axes, CSS effects on converted HTML labels, and implicit PDF viewports that may clip painted content. These fidelity diagnostics preserve default output. Use explicit SVG dimensions or a `viewBox` to control PDF clipping. `--quiet` suppresses warnings. ## Command Dialects And Root Compatibility Root-level render flags no longer belong to the advertised command tree. Keeping native and compatibility arguments in separate parsers gives each workflow its own defaults, validation, help, completion output, input rules, and publication guarantees without breaking existing root-level `mmdc` scripts. | Upstream syntax or former 0.8.x native spelling | Current explicit syntax | | --- | --- | | `mmdc -i diagram.mmd -o diagram.svg` | `merman-cli mmdc -i diagram.mmd -o diagram.svg` | | `merman-cli -i diagram.mmd -o diagram.svg` | `merman-cli mmdc -i diagram.mmd -o diagram.svg` | | `merman-cli -i diagram.mmd -o diagram.png -t dark` | `merman-cli mmdc -i diagram.mmd -o diagram.png -t dark` | | `merman-cli -i README.md -o README.rendered.md --artifacts docs/assets` | `merman-cli mmdc -i README.md -o README.rendered.md --artifacts docs/assets` | | Native single render through shared flags | `merman-cli render diagram.mmd --output diagram.svg` | | Native Markdown through extension inference | `merman-cli batch README.md --output-dir README.merman` | | `merman-cli render diagram.mmd -e png` | `merman-cli render diagram.mmd -f png` | | `merman-cli batch README.md -e png` | `merman-cli batch README.md -f png` | An invocation whose first argument is an option owned by `mmdc`, such as `-i` or `--input`, is forwarded to the same parser and execution path as `merman-cli mmdc`. When stdin is a terminal, the root alias requires `-i INPUT` or an explicit `-i -`. This silent compatibility alias is intentionally absent from help and completions. Explicit `merman-cli mmdc` remains the preferred compatibility spelling because it makes the selected contract visible to readers and tooling. Bare root inputs and native-only root options exit `2` with a targeted message pointing to `mmdc`, `render`, and `batch`. New scripts should choose an explicit subcommand. Native `render` and `batch` use `-f/--format`; their former `-e` aliases are removed in 0.9.0. The separate `merman-cli mmdc -e/--outputFormat` interface remains part of the pinned compatibility contract. See the [upgrade guide](https://github.com/Latias94/merman/blob/main/docs/release/V080_TO_V090_UPGRADE_GUIDE.md) when migrating native scripts from 0.8.x. The `mmdc` subcommand is a release-pinned compatibility snapshot. This release follows the supported command behavior of `@mermaid-js/mermaid-cli@11.16.0`; future changes are tied to an explicit Mermaid baseline update. See the [compatibility register](https://github.com/Latias94/merman/blob/main/docs/alignment/CLI_COMPATIBILITY.md) for exact coverage and deliberate browserless divergences. `mmdc -t/--theme` accepts `default`, `forest`, `dark`, and `neutral`. Omitting the value selects `default`, matching the pinned Mermaid CLI. `mmdc --configFile` can override that selection. ## Diagram themes Use `--theme` with `render` and `batch` to select a Merman preset, a local `.json` theme document, or a Mermaid theme ID such as `forest`. Use `--theme -` to read a v2 document from stdin when Mermaid or Markdown input comes from a file. ```sh merman-cli render diagram.mmd --theme studio --appearance dark -o diagram.svg merman-cli render diagram.mmd --theme forest --background '#F8FAFC' -o diagram.svg merman-cli render diagram.mmd --theme studio --appearance dark -f unicode --ascii-color truecolor merman-cli batch README.md --output-dir generated --theme theme.json --appearance light ``` `--appearance light|dark` selects the appearance of a Merman preset or Theme v2 document supplied with `--theme`. When omitted, the compiler uses the theme's default. Color-enabled ASCII and Unicode use the native theme's semantic palette. `--background COLOR` changes the graphical canvas for any theme. For example, `--background transparent` clears the canvas base paint. Textures remain visible where defined. An explicit theme ID takes precedence over the selection in `--config-file`. The default `--theme-precedence host` also prefers the CLI selection over a source-authored Mermaid theme. Use `--theme-precedence source` to let a diagram that declares a Mermaid theme use that theme. For `parse` and `layout`, an explicit `--theme` also overrides the file's theme, while source-authored themes keep their normal precedence. `mmdc` follows the upstream `--configFile` precedence. Graphical rendering writes theme notices to stderr. Use `--quiet` to suppress them. ```sh merman-cli theme list merman-cli theme list --json merman-cli theme export studio --minimal -o theme.json merman-cli theme check theme.json --appearance dark --strict-contrast merman-cli theme check - --json ``` `theme list` shows default-appearance swatches in the terminal. Redirected output displays the swatches as hex colors. `theme list --json` prints the shared schema-2 catalog with presets, Mermaid theme IDs, and family capabilities. `theme export` writes the editable preset document. With `--minimal`, it writes an `extends` template where you can set `seed.accent`, the `typography` font stacks, or `form.radius`. `theme check` reads a file or piped stdin and validates the schema-2 document. It checks all available appearances, including those inherited via `extends`, unless `--appearance` selects one. `--strict-contrast` exits with status `1` if any checked appearance misses a contrast target. In `--json` output, top-level `ok` is the aggregate check result. Top-level theme details describe the selected or primary appearance. When more than one appearance is checked, `appearances` contains the status, resolved theme, contrast ratios, and notices for each one. For invalid documents, JSON includes a message and, when available, the line, column, and JSON path. The exit status is `2`. ## Markdown Batches Native batch rendering owns one output directory: ```sh merman-cli batch README.md # writes README.merman/README.md, numbered assets, a manifest, and a stable lock merman-cli batch docs/guide.md --output-dir generated --format pdf ``` All charts render into staging before publication. The rewritten document is published last, and an interrupted commit is recovered under the output lock before new work starts. Native `batch` removes a stale artifact only when its byte length and SHA-256 match the prior validated manifest. Modified artifacts and artifacts listed in older manifests without digests are retained. `--quiet` suppresses the retention notices. Switching output formats migrates the same managed generation and applies the same checks to prior-format artifacts. A document with no eligible charts is a valid generation. Native `batch` recognizes backtick, tilde, and colon Mermaid fences inside blockquotes and lists, but ignores fence-like text in HTML comments and indented code. When the output document moves to another directory, existing relative Markdown links, images, and reference destinations are rebased from the input document's directory. For stdin, the working directory is the input base. Absolute URLs, fragment links, and generated diagram links are not rebased. The output lock serializes cooperating Merman commands. Each entry is checked against its retained identity, prior contents and permissions before publication; complete target checks also run at transaction boundaries, before the final document or receipt, and before the committed marker. Other programs can still change files during publication. An unrelated conflict may be detected after more entries have been published, and a transient change that is restored between checks may go unseen. Publication does not provide an atomic multi-file snapshot or continuous conflict detection. If a conflict prevents safe recovery, the command retains transaction evidence and reports the failure instead of overwriting unknown contents. On Unix, recovery of an interrupted publishing or rollback phase compares target contents before treating changed permissions as a mode-only conflict. If permissions prevent reading a target, that recovery retains the target and transaction evidence instead of replacing unverified contents. Restore the intended read access and rerun the command to let recovery inspect the retained generation. A transaction already marked committed or rolled back only finishes cleanup. If files are temporarily unavailable during rollback, release them and rerun the command. Recovery inspects each target against the retained generation, including when an older journal recorded a higher rollback cursor on a retry. Once recovery succeeds, the same invocation can publish the requested generation using the identities of files restored under the lock. Stdin requires an explicit logical name and output directory: ```sh cat README.md | merman-cli batch - \ --stdin-file-name README.md \ --output-dir README.merman ``` The `parallel-markdown` Cargo feature adds bounded scheduling on dedicated chart workers and the `--jobs` option for `batch` and `mmdc` Markdown input. It implies `markdown`. Without it, `batch` renders charts serially. Strict `mmdc` Markdown uses the pinned upstream fence scanner and output naming. To keep recovery honest, its rewritten document and artifacts must remain below one transaction root on one filesystem; split-root layouts are rejected before output creation or network access. Changing `-e` or `--artefacts` publishes the new namespace but leaves files from the previous namespace untouched. ## Rustdoc Fragments `merman-cli rustdoc` is the CLI-first integration for crates that want static Mermaid diagrams in Rustdoc without placing Merman, layout engines, math rendering, or a procedural macro in the consuming crate's normal or build dependency graph. The CLI is an authoring and CI tool: it renders the complete bundle ahead of `cargo doc`, and the crate consumes only committed Markdown through Rust's built-in `include_str!`. Place `merman-rustdoc.toml` at the crate root so its fixed managed output root is `docs/generated/merman-rustdoc/`: ```toml schema = 1 [[fragments]] id = "crate-overview" source = "docs/rustdoc-src/crate-overview.md" [[fragments]] id = "render-module" source = "docs/rustdoc-src/render-module.md" source_display = "details" ``` `source` is relative to the directory containing the configuration. Markdown sources may contain backtick or tilde Mermaid fences and standalone `include_mmd!("diagrams/architecture.mmd")` lines; include paths are also relative to the configuration root. Raw `.mmd` and `.mermaid` files are accepted as one-diagram fragments. `source_display` is optional and is either `hide` (the default) or `details`, which adds the Mermaid source below each rendered diagram in a collapsed block. Fragment IDs are portable ASCII identifiers and become `.md` filenames. The output directory cannot be redirected by configuration. Rename an ID through a temporary, distinctly spelled ID in two builds when only its ASCII case changes; direct case-only renames are rejected so the same history behaves on every filesystem. The fixed managed root has one owner: a receipt created by one configuration filename cannot be replaced or cleaned by a different configuration in the same package directory. Move or remove the old managed root explicitly before adopting it with a different configuration. Build or verify the bundle: ```sh merman-cli rustdoc build merman-cli rustdoc check --quiet # A workspace member can keep its own configuration and managed root. merman-cli rustdoc build --config crates/my-crate/merman-rustdoc.toml merman-cli rustdoc check --config crates/my-crate/merman-rustdoc.toml --quiet ``` `build` renders and validates the complete expected bundle before publishing it transactionally. It writes `receipt.json` last, removes only stale files owned by the previous valid receipt, leaves unknown neighboring files alone, and preserves unchanged files on a no-op rebuild. It never overwrites the configuration, Markdown sources, or included Mermaid files. `check` performs the same bounded generation in memory, compares the exact receipt-owned file set, receipt, and fragment bytes, and never writes. A stale or missing generation exits `1`, invalid invocation or configuration exits `2`, and an invalid receipt, unfinished publication, or other operational failure exits `3`. `check` lists stale and missing fragments together and suggests rebuilding. Both commands accept `--resource-profile` and `--resource-limit`. When `parallel-markdown` is enabled, `--jobs` caps worker concurrency. Consume generated fragments at crate or item scope without a documentation dependency: ```rust #![doc = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), "/docs/generated/merman-rustdoc/crate-overview.md" ))] #[doc = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), "/docs/generated/merman-rustdoc/render-module.md" ))] pub mod render {} ``` Include each generated fragment at most once on one rendered Rustdoc page. Its SVG DOM IDs are deterministic within the fragment, so including the same fragment twice would duplicate those IDs. Commit the configuration, authoring sources, generated fragments, and `receipt.json` together. Review an intentional regeneration before staging it: ```sh merman-cli rustdoc build git diff -- merman-rustdoc.toml docs/rustdoc-src docs/generated/merman-rustdoc ``` To abandon the whole local documentation change, restore the configuration, source paths, and managed output paths with Git. To keep the source change but discard only generated edits, restore the managed directory and run `rustdoc build` again; `rustdoc check` will deliberately report stale output until the generated bundle matches the retained sources. ```sh # Substitute the source paths used by your configuration. git restore -- merman-rustdoc.toml docs/rustdoc-src docs/generated/merman-rustdoc ``` Run freshness verification before Rustdoc in CI: ```sh merman-cli rustdoc check --quiet cargo doc --no-deps ``` Pin the same CLI release or reviewed source revision in authoring and CI. The receipt binds the generator version, Mermaid baseline, capability descriptor, configuration, sources, and output hashes, so an intentional tool upgrade requires one reviewed `rustdoc build` regeneration. docs.rs does not run `merman-cli`; it documents the uploaded Cargo package. Ensure the generated fragments are committed and included in the package, especially when `Cargo.toml` has an explicit `include` whitelist. Inspect the package boundary before publishing: ```sh cargo package --list --allow-dirty ``` The generated-fragment path and the independent [`merman-rustdoc`](https://github.com/Latias94/merman/tree/main/crates/merman-rustdoc#readme) attribute macro are peer products. Neither invokes, discovers, or falls back to the other: | Concern | `merman-cli rustdoc` | `merman-rustdoc` attribute macro | | --- | --- | --- | | Cargo dependency cost | No Merman renderer dependency in the consuming crate | Compiles the selected procedural-macro and renderer closure | | Authoring loop | Explicit `build`; CI uses read-only `check` | One-step rendering while `cargo doc` runs | | Rustdoc scope | Crate and item docs through `include_str!` | Item docs and recursive inline item trees; not crate-level `//!` or `#[doc = include_str!(...)]` content | | Generated ownership | Markdown fragments and receipt are committed and reviewable | Source comments stay unchanged; SVG exists only in generated Rustdoc output | | docs.rs | Uses packaged static files with no documentation feature | Requires the optional macro dependency and docs.rs feature to be enabled | | Failure timing | Authoring build or CI freshness gate, before `cargo doc` | During macro expansion in `cargo doc` | | Rollback | Restore source/config/output as one Git change, or rebuild the retained source | Revert the annotated Rust source or feature selection | Choose the CLI path for published libraries, workspaces, reproducible packaging, crate-level docs, or any project sensitive to Cargo dependency closure. Choose the macro when one-step `cargo doc` ergonomics outweigh the compile cost and item-level attribute placement is the desired ownership model. A migration is additive and reversible: move the annotated prose to an external Markdown source, declare a fragment, run `rustdoc build`, replace the attribute with `#[doc = include_str!(...)]`, add the CI check, and remove the optional macro dependency only after no annotated items remain. ## Analysis And Fixes The `analysis` capability enables parser-backed diagnostics, deterministic fix selection, and rule metadata: ```sh merman-cli detect diagram.mmd merman-cli parse diagram.mmd --pretty --meta merman-cli layout diagram.mmd --pretty merman-cli layout diagram.mmd --snapshot --pretty merman-cli lint diagram.mmd --format json merman-cli lint README.md --markdown --format text merman-cli lint-rules --configurable --format json ``` Starting with 0.11.0 (CLI contract 8), `layout` returns schema-1 geometry with a family identifier. Add `--snapshot` for the full `meta`, `semantic`, and `layout` envelope. For consumers using `--suppress-errors`, the snapshot also retains the original parse diagnostic. On 0.10.x (contract 7), use `layout` by itself to get the full envelope. `fix` has one explicit output mode: ```sh merman-cli fix diagram.mmd # fixed source on stdout merman-cli fix diagram.mmd --check # exit 1 when source would change merman-cli fix diagram.mmd --diff # print diff; exit 1 when it changes merman-cli fix diagram.mmd --output fixed.mmd merman-cli fix diagram.mmd --write ``` Use repeatable `--rule RULE_ID` or `--fix STABLE_FIX_ID` selectors when automation needs a narrower edit plan. Duplicate edit sets are applied once, alternative fixes remain alternatives, and conflicting selections fail before publication. `--write` atomically replaces the canonical input target after checking that its identity and complete bounded contents still match the acquired snapshot. ## Choose A Build The source defaults to the standard diagram CLI with `all-diagrams` and the Rustdoc authoring command. For a slim binary, disable defaults and select the required `diagram-*` families plus operation leaves. Use `all-diagrams` to retain the full language surface. The recipes below select families explicitly: | Build | Capabilities | | --- | --- | | `--no-default-features --features all-diagrams` | `detect`, `parse`, and `capabilities` | | `--no-default-features --features all-diagrams,analysis` | Lint and rule metadata without render dependencies or replacement generation | | `--no-default-features --features all-diagrams,fixes` | Lint, the fix command, and rule metadata without render dependencies | | `--no-default-features --features diagram-sequence,diagram-pie,svg` | Deterministic SVG using the diagram families’ own layouts | | `--no-default-features --features all-diagrams,native-fonts,layout-dagre` | SVG with explicit-font measurement and the Dagre adapter | | `--no-default-features --features all-diagrams,ascii` | ASCII/Unicode without SVG | | `--no-default-features --features all-diagrams,markdown,layout-dagre` | Sequential native Markdown batch and SVG with Dagre | | `--no-default-features --features all-diagrams,rustdoc,layout-dagre` | Static Rustdoc fragment build/check with Dagre and Cytoscape. Add `math` for mathematical labels | | `--no-default-features --features all-diagrams,icons,layout-dagre` | SVG plus bounded local Iconify packs | | `--no-default-features --features all-diagrams,png,layout-dagre` | SVG and PNG with Dagre | | `--no-default-features --features all-diagrams,pdf,layout-dagre` | SVG and vector PDF with Dagre | Install a lint-only binary: ```sh cargo install merman-cli --version 0.12.0 --locked \ --no-default-features --features all-diagrams,analysis ``` Additional leaves are `jpeg`, `layout-cytoscape`, `layout-dagre`, `layout-elk`, `layout-grid`, `layout-layered`, `layout-shoal`, `math`, `network-icons`, `parallel-markdown`, `shell-completions`, `system-clock`, `system-timezone`, `system-random`, and `system-timing`. The default includes ELK and its EPL-2.0 notice and provenance. Lean builds can omit ELK with `--no-default-features`. Features such as `png` and `network-icons` enable `svg` and `icons`, respectively. In a source build, enable `layout-grid` and the matching Flowchart, Swimlane, Agentflow, Class, ER, Mindmap, Requirement, State, or Usecase diagram feature to use `layout: grid` in diagram or site config. `merman-cli capabilities --json` reports `layout-grid` when the built CLI can accept that selection. Enable `layout-layered` and the same diagram features for `layout: layered`. Add `layout-dagre` to allow a retry after a recoverable Layered error. The current source build requires an explicit layout leaf for defaults-off recipes that render ordinary graph diagrams. Default and release CLI builds include Dagre, ELK, Cytoscape, and Shoal (selected explicitly with `layout: shoal`). Defaults-off builds can omit `layout-shoal` or select it explicitly. [Graph layout feature recipes](https://github.com/Latias94/merman/blob/main/docs/FEATURES.md#svg-without-general-purpose-layout-engines) Use `merman-cli capabilities --json` as the machine-readable authority for the installed artifact. The document reports `schema_version: 2` and `cli_contract_version: 9`, package and pinned compatibility versions, descriptor digest, compiled commands, `diagram_families`, capabilities, and outputs. `diagram_families` lists the compiled parser families. Use the corresponding output capabilities to determine SVG or ASCII availability. SVG-enabled artifacts expose `theme list --json` for the shared theme catalog. For native-font builds, `native_fonts.default_policy_scope` is `mermaid-svg-input`: `default_measurement`, `default_font_source`, and `default_system_discovery` remain `deterministic`, `none`, and `disabled`. The additive `encoded_output_defaults` object reports `measurement: "native"`. Builds with only bounded system discovery report `font_source: "bounded-system-discovery"` and `system_discovery: "before-layout"`. Current source defaults and release-profile builds report `platform-managed-system-query` and `platform-initialization-then-on-demand-families` for the encoded font source and discovery policy. Without `system-fonts`, the three values are `deterministic`, `none`, and `disabled`. Explicit font sources enable native measurement with a closed set. Use `--font-system on` to permit system fallback with the build's default provider. `legacy_export_paths` describes which input routes use the codec font environment. It covers deterministic Mermaid exports. Builds without `system-fonts` also use that environment for raw SVG without font options. The contract preserves the native `-f` spelling, text-first `lint`, narrowed `detect` surface, and feature-gated top-level `rustdoc` workflow. ASCII-enabled builds additionally expose an `ascii` subcontract with its own schema version, report schemas and streams, family layout/width/encoding/fallback arrays, and detector-to-family mappings. Automation should version-check the CLI contract independently from the outer JSON schema. ## Rendering And Runtime Policy `merman-cli render diagram.mmd --format svg --svg-pipeline static` writes SVG for fixed markup. It emits the Flowchart-family container palette slots used by the diagram and preserves the rendered links, accessibility metadata, viewBox, and authored styles. Native PNG, JPEG, and PDF rendering uses static generation followed by resvg-safe conversion. Ordinary SVG and `mmdc` default to the complete stylesheet. For the Rust API and publication contracts, see the [SVG output pipeline](https://github.com/Latias94/merman/blob/main/docs/rendering/SVG_OUTPUT_PIPELINE.md). Native `render` rejects options that are irrelevant to the selected output before reading input or creating output. Examples: ```sh merman-cli render diagram.mmd --format svg --svg-pipeline readable merman-cli render diagram.mmd --format png --raster-fit-width 1600 merman-cli render diagram.mmd --format pdf --pdf-filter-scale 4 merman-cli render diagram.mmd --format unicode --ascii-color auto merman-cli render diagram.mmd --format unicode --ascii-layout-profile compact \ --ascii-max-width 80 --ascii-overflow fallback --ascii-report merman-cli render diagram.mmd --format unicode --ascii-color plain \ --ascii-graph-presentation adaptive --ascii-layout-profile auto \ --ascii-max-width 80 --ascii-overflow fallback --ascii-report ``` `--ascii-graph-presentation` is available from 0.11.0. PNG/JPEG use a bounded Rust raster pipeline. PDF keeps vector geometry and bounds localized filter and embedded-image raster work. They are not Chromium screenshots. ASCII/Unicode support is family-specific; see the [support matrix](https://github.com/Latias94/merman/blob/main/docs/rendering/ASCII_SUPPORT_MATRIX.md). For Flowchart, Swimlane, and State, `--ascii-node-padding-y 0` removes blank rows inside ordinary node frames. `--ascii-node-padding 0` sets both axes; `--ascii-node-padding-x` and `--ascii-node-padding-y` override that scalar independently. The default remains one cell. `--ascii-graph-padding-x` and `--ascii-graph-padding-y` control preferred gaps between ranks, including under Compact. Layout still reserves required space for frames, labels, and arrows. These switches apply to text rendering. ```sh merman-cli render diagram.mmd --format unicode --ascii-node-padding-y 0 ``` For a flat Flowchart with strict graph presentation, `--ascii-graph-routing-space fixed` attempts the requested node padding and rank gaps with the space required by shape and stroke geometry. If routing reports exhausted search or port capacity, retry with `expand` to reserve more space. `expand` is the default. ```sh merman-cli render diagram.mmd --format unicode --ascii-node-padding-y 0 \ --ascii-graph-padding-y 2 --ascii-graph-routing-space fixed --ascii-report ``` `--ascii-report` is a machine-safe JSON channel. It always emits Plain text: `--ascii-color auto` resolves to Plain in report mode, while an explicit ANSI16/ANSI256/TrueColor/HTML request is rejected. The report uses ASCII output schema 4 and includes `encoding`, logical primary/emitted extents, width profile, and typed overflow/fallback state. `requested_layout_profile` records the request and `compact_attempted` records whether Auto tried Compact. `primary_width`, `primary_height`, `layout_profile`, and `primary_overflowed` are null together when no primary geometry was accepted; a real empty primary retains zero dimensions. `emitted_overflowed` always describes the complete emitted text. A final line terminator is not counted as another logical row. Viewport fallback is Plain-only; styled/fallback combinations are invalid even if the input fits. `compact` and `auto` are admitted only for Flowchart, Swimlane, and Sequence, and Auto requires an explicit `--ascii-max-width`. Other supported families use `canonical`. Once report mode is selected, failures use ASCII error-report schema 1 on stderr with a stable code, category, terminal-safe message, and typed details; stdout and the requested output target remain unpublished. Graph presentation defaults to `strict`. Agentflow, Flowchart, Requirement, Swimlane, and State may opt into `adaptive` with Plain output to recover an admitted routing/capacity miss as a complete keyed graph document. The report records `requested_graph_presentation` and a reason of `routing_search_exhausted` or `port_capacity_exceeded`; `primary_overflow` remains the separate width-fallback reason. Adaptive Auto may try Compact after a Canonical planning miss, while State remains Canonical-only. Width `allow`, `error`, and `fallback` still govern valid candidates independently. Unsupported semantics, allocation/resource failure, and cancellation return errors. Unbounded work policy does not remove finite algorithmic search allowances; see the [graph planning boundary](https://github.com/Latias94/merman/blob/main/crates/merman-ascii/README.md#graph-presentation-boundary). ## Runtime Policy Runtime behavior is deterministic by default, using Unix epoch time, UTC, and a fixed operation seed even when system adapters are compiled. This also applies to `mmdc` and is a deliberate divergence from Chromium's ambient date, time zone, and randomness. A complete default binary can opt into upstream-like host state: ```sh merman-cli render diagram.mmd --runtime native merman-cli mmdc -i diagram.mmd -o diagram.svg --runtime native ``` Each adapter is also independently selectable with `--system-clock`, `--system-timezone`, `--system-random`, or `--system-timing` when its feature is compiled. `--runtime native` is shown only when the clock, time-zone, and random adapters are all available. Timing remains separately opt-in. Native-context font discovery is controlled by the font options above; `--runtime native` alone does not select it. With `--system-timing`, `parse` reports the elapsed time for resource admission, parsing, and compatibility JSON projection. To replay a host-captured clock precisely, pass `--fixed-unix-millis` and the corresponding fixed local offset. These controls are available without system adapters: ```sh merman-cli render diagram.mmd --fixed-unix-millis 1781046000375 --fixed-local-offset-minutes 480 merman-cli mmdc -i diagram.mmd -o diagram.svg --fixed-unix-millis 1781046000375 --fixed-local-offset-minutes 480 ``` `--fixed-unix-millis` accepts an integer from `-8640000000000000` through `8640000000000000`, inclusive, matching the JavaScript Date range. It preserves the exact millisecond instant, including the Gantt Today Marker position. The selected time zone determines the local calendar date used by date parsing; changing the fixed offset does not shift the supplied instant. Omitting the offset preserves the selected policy's time zone, which is UTC by default. `--fixed-today YYYY-MM-DD` instead freezes the clock at that date's local midnight and cannot be combined with `--fixed-unix-millis`. Both forms preserve deterministic randomness unless a different random source is explicitly selected. ## Operation Control `render`, `batch`, `mmdc`, `layout`, `theme check`, `theme export`, `rustdoc build`, and `rustdoc check` use cooperative cancellation from input acquisition through publication. Ctrl-C requests cancellation and returns exit status `130` after cleanup. Press Ctrl-C again for an immediate exit. Use `--operation-timeout-ms MILLISECONDS` on commands that expose it to add a relative monotonic deadline: ```sh merman-cli render diagram.mmd --operation-timeout-ms 5000 merman-cli batch README.md --operation-timeout-ms 30000 merman-cli mmdc -i diagram.mmd -o diagram.svg --operation-timeout-ms 5000 merman-cli layout diagram.mmd --operation-timeout-ms 5000 merman-cli theme check theme.json --operation-timeout-ms 5000 merman-cli rustdoc check --operation-timeout-ms 30000 ``` Omitting this option sets no operation deadline. Zero cancels at the first cooperative checkpoint. The deadline is independent of resource budgets, including an unbounded resource profile. It is operation-wide, including stdin and bounded file acquisition. It can expire while a stdin producer keeps its pipe open without sending data. A Markdown batch does not reset it for each chart, and parallel chart workers observe the same cancellation state. Cancellation is cooperative: a blocking host or backend call returns to a checkpoint before the request is observed. Once observed, cancellation emits no partial rendered document; file and Markdown generation paths check the control while staging output and preserve their existing atomic or recoverable transaction guarantees. ## Resource And Network Policy `--resource-profile` derives one complete budget for source/config/CSS/icon acquisition, chart count, staging, render working set, jobs, redirects, and network duration: | Profile | Intended input | | --- | --- | | `constrained` | Untrusted, public, or multi-tenant | | `interactive` | Cooperative editor-like work | | `trusted-native` | Controlled local automation; CLI default | | `unbounded-for-trusted-input` | Explicitly trusted work that owns its cost | Use repeatable `--resource-limit STABLE_ID=POSITIVE_U64` only for a scoped override. The unbounded profile retains hard protocol guards, finite network timeouts, redirect limits, overflow checks, renderer-owned icon-registry ceilings, and backend capabilities. `parse`, `lint`, and `fix` apply the selected profile to the source and each diagram model. They accept overrides for `max_source_bytes`, `max_model_items`, `max_model_text_bytes`, `max_model_nesting_depth`, and `max_config_bytes`. If analysis exceeds a resource ceiling, `fix` exits with status `1` before applying changes or publishing output. For ASCII/Unicode, the CLI's default `trusted-native` profile allows 8,000,000 layout work units. If a trusted diagram exceeds it, increase that budget alone, or explicitly remove all policy budgets and set an operation deadline: ```sh merman-cli render diagram.mmd --format unicode --resource-limit max_ascii_layout_work_units=64000000 merman-cli render diagram.mmd --format unicode --resource-profile unbounded-for-trusted-input --operation-timeout-ms 30000 ``` The second command removes all policy budgets, including output and model ceilings; it is not a work-only override. A resource error's `actual` value is the first rejected charge, not the total required to finish, so neither a larger budget nor an unbounded profile guarantees completion. Timeout cancellation remains cooperative. Resource exhaustion and cancellation return an error without publishing a partial text diagram, including when viewport fallback is enabled. Local icon packs stay offline: ```sh merman-cli render diagram.mmd \ --icon-pack @iconify-json/logos merman-cli render diagram.mmd \ --icon-pack-source logos#icons.json ``` Icon acquisition and renderer admission are separate bounded stages. The CLI can accept at most 16 packs, 16 MiB for one local or remote pack, and 32 MiB in aggregate; constrained profiles are tighter. No profile or override can exceed those renderer-owned constructor capabilities. Each acquired body is then passed as raw bytes to the shared transactional IconifyJSON builder, which validates JSON structure, identifiers, geometry, aliases, SVG bodies, retained memory, and build work before publishing an immutable registry. A failed pack publishes no partial registry. Local package/path lookup and optional HTTP acquisition belong only to the CLI `icons` and `network-icons` features. The `merman` and `merman-render` Rust library surfaces include icon registry construction in their existing `svg` capability and do not pull CLI lookup, URL, DNS, HTTP, Tokio, or filesystem-acquisition dependencies. HTTP(S) sources require `network-icons` plus `--allow-network`. Loopback, private, link-local, multicast, and unspecified destinations additionally require `--allow-private-network`. Every redirect is resolved and authorized again; diagnostics redact URL credentials, paths, queries, and fragments. ## Existing SVG Input PNG, JPEG, and PDF builds can convert a named `.svg` file directly: ```sh merman-cli render diagram.svg --format png --output diagram.png ``` Named `.svg` files are inferred by extension. Use `--input-kind svg` for SVG read from stdin or from a file with another extension. Raw SVG conversion is native-only and passes through the same bounded sanitizer/export pipeline. ## Exit And Output Contracts | Exit | Meaning | | ---: | --- | | `0` | Success, including a closed downstream stdout pipe | | `1` | Invalid Mermaid/content/render result, deadline expiration, a source-required layout or math capability is unavailable, or `fix --check/--diff` would change source | | `2` | Invalid invocation, conflicting options, unavailable statically requested option/output capability, or configuration | | `3` | Local/remote operational failure, lock contention, incomplete recovery, or publication failure | | `130` | Cooperative cancellation requested by Ctrl-C | stdout contains only the requested SVG, image, text, JSON, diff, fixed source, or completion payload. `--quiet` suppresses informational and timing diagnostics where supported; errors remain visible. ## Completions And Man Pages A binary built with `shell-completions` generates completions that contain only its compiled commands: ```sh source <(merman-cli completion bash) merman-cli completion zsh > _merman-cli merman-cli completion fish > merman-cli.fish merman-cli completion powershell > merman-cli.ps1 ``` Release archives beginning with `0.8.0-alpha.5` also carry deterministic completion snapshots and manual pages so downstream package definitions can install shell integration without executing a foreign-target binary during packaging. These assets are generated from the same Clap command tree and checked for drift in CI. Homebrew stable integration is monitored by this repository. Scoop's main bucket provides `merman-cli`; see the [host guide](https://github.com/Latias94/merman/blob/main/docs/release/PREBUILT_PRODUCTS.md) for available package-manager versions. Each external channel follows its own release schedule. The checked-in completion and manual assets represent the canonical `cli-release` complete profile. For a custom slim build with `shell-completions`, generate completion from that binary at runtime so omitted commands, options, and values stay omitted. A build without that feature has no `completion` subcommand. ## License Merman's own code is licensed under either Apache-2.0 or MIT at your option. The current source Cargo default and the `cli-release` archive include the EPL-2.0 ELK implementation. Only the `cli-release` archive includes the RaTeX math/font closure; Cargo source defaults leave math opt-in. Explicit lean source builds can exclude ELK by disabling default features. Release archives include the matching `THIRD_PARTY_NOTICES.md` and `THIRD_PARTY_LICENSES/`; source-built distributions must carry the notices for the features they select.