Who's Actually Playing Your SVG Animation? Turning Mermaid Step Sequences Into GIFs
Anyone building slide decks, documents, or printed handouts from Mermaid step-sequence diagrams will hit the gap between a browser-playing SVG and a static PNG; this workflow defines a deterministic path from SVG to GIF, including the `begin`/`dur` math, reduced-motion handling, and version checks that otherwise cause silent failures.
Mermaid's step-number animation isn't a rendering-time feature: the exported SVG carries its own SMIL and CSS declarations, so Chrome plays it directly and even an `<img>` tag keeps it moving. Static converters such as `rsvg-convert`, `cairosvg`, and ImageMagick don't run that timeline; they draw one DOM snapshot, and they also drop the HTML text inside `<foreignObject>`, leaving Chinese node labels empty. The only reliable route to a GIF is a headless browser that seeks the SVG timeline with `setCurrentTime(t)` and captures frames.
That process requires reading the loop period from the `begin` and `dur` attributes, explicitly disabling reduced-motion, and verifying the output with frame hashes. A short script wraps that loop and hands the frames to ffmpeg. The same script also relies on mermaid 12.3.0, the first version with the `stepNumbers` syntax; 12.2.0 silently ignores it.
An exported SVG is still a self-contained animation document; only a raster format like PNG freezes a frame.
rsvg-convert and its peers treat foreignObject as opaque, so any SVG with embedded HTML loses text even before animation is considered.
A CLI update can silently ship a new renderer; the real mermaid version lives in the lockfile, and that determines whether step-number syntax works.
Actually doesn't touch .mmd; that term was removed after the modification.