# Render a chart

Render each `.mmd` file that you show with the npm package `pele@1.9.0`, and give the operator the SVG. Install Pele once, outside the repo. Write each SVG next to its `.mmd` file, with the same name. The API is at https://pele.run/api. Pass `{ limit: 1_000_000, outputLimit: 8_000_000, maxEdges: 10_000 }` as the options of `render`. Pele's defaults are smaller than a chart of 500 states can be. When Pele throws a `PeleError`, show the operator the Mermaid text and the error.

## Colors

Pele ignores Mermaid `theme` and `themeVariables`. Set its `--pele-*` CSS variables on `.pele`. https://pele.run/theming lists them.

For TLA+ statecharts (`stateDiagram-v2`), the command gives each state the color class of its group, such as `class sN teal`. It marks each bad state with `class sN breaks` or `class sN mayBreak`, each state on the shortest path to a bug with `class sN bugPath`, and each state that a PROPERTY counterexample repeats forever with `class sN repeats`. The `.mmd` file has a `classDef` line for `breaks` and for `mayBreak`, and none for the group colors, `bugPath`, or `repeats`.

For Lean 4 proof charts (`flowchart TD`), `lemmas.mmd` and `proof.mmd` emit `classDef` and `class` assignments for `target`, `goalRoot`, `subRoot`, `termRoot`, `closed`, `sorry`, `error`, `open`, `axiom`, `native`, `restsOn`, `doubtPath`, `folded`, `stub`, and `note`. Flowchart nodes render as `rect`, `polygon`, or `circle` depending on shape, so the CSS rules below target all three elements.

Pele writes each `classDef` color as an inline `style` attribute on the node, and a `style` attribute wins over a normal CSS rule. The mark rules below therefore use `!important` so dark themes override the light `classDef` colors. Put the mark rules after the group colors so a mark shows over a group color.

Put this `<style>` block at the start of each SVG so the image follows the light or dark setting of the viewer.

```css
.pele {
  --pele-bg: #ffffff;
  --pele-fg: #1c1c1c;
  --pele-muted: #656565;
  --pele-line: #808080;
  --pele-surface: #fcfcfc;
  --pele-surface-alt: #f1f1f1;
  --pele-border: #c9c9c9;
}
.pele .blue rect { fill: #c3e0ff; }
.pele .orange rect { fill: #f0d3bf; }
.pele .purple rect { fill: #e3d5ff; }
.pele .yellow rect { fill: #f0dcbf; }
.pele .teal rect { fill: #bfe3df; }
.pele .tan rect { fill: #e5d9ce; }
.pele .pink rect { fill: #ffcbe6; }
.pele .breaks rect {
  fill: #ffecee !important;
  stroke: #e72e3b !important;
  stroke-width: 2.5px !important;
}
.pele .breaks text {
  fill: #cd2834 !important;
}
.pele .mayBreak rect {
  fill: #fff3e6 !important;
  stroke: #e8730c !important;
  stroke-width: 2.5px !important;
}
.pele .mayBreak text {
  fill: #b85a06 !important;
}
.pele .bugPath rect {
  stroke: #1680f3 !important;
  stroke-width: 2.5px !important;
}
.pele .repeats rect {
  stroke: #9b35d6 !important;
  stroke-width: 2.5px !important;
  stroke-dasharray: 6 3;
}
.pele .target rect, .pele .target polygon, .pele .target circle {
  fill: #e8f2ff !important;
  stroke: #1680f3 !important;
  stroke-width: 2.5px !important;
}
.pele .target text { fill: #0d4ea6 !important; }
.pele .goalRoot rect, .pele .goalRoot polygon, .pele .goalRoot circle {
  fill: #e8f2ff !important;
  stroke: #1680f3 !important;
  stroke-width: 2px !important;
}
.pele .goalRoot text { fill: #0d4ea6 !important; }
.pele .subRoot rect, .pele .subRoot polygon, .pele .subRoot circle {
  fill: #eef2ff !important;
  stroke: #6366f1 !important;
  stroke-width: 2px !important;
}
.pele .subRoot text { fill: #3730a3 !important; }
.pele .termRoot rect, .pele .termRoot polygon, .pele .termRoot circle {
  fill: #f0fdfa !important;
  stroke: #0d9488 !important;
  stroke-width: 2px !important;
}
.pele .termRoot text { fill: #115e59 !important; }
.pele .closed rect, .pele .closed polygon, .pele .closed circle {
  fill: #e9f7ef !important;
  stroke: #229954 !important;
  stroke-width: 1.5px !important;
}
.pele .closed text { fill: #145a32 !important; }
.pele .folded rect, .pele .folded polygon, .pele .folded circle {
  fill: #f3ecff !important;
  stroke: #8b5cf6 !important;
  stroke-width: 1.5px !important;
}
.pele .folded text { fill: #5b21b6 !important; }
.pele .stub rect, .pele .stub polygon, .pele .stub circle {
  fill: #f4f4f5 !important;
  stroke: #71717a !important;
  stroke-width: 1.5px !important;
  stroke-dasharray: 5 3;
}
.pele .stub text { fill: #52525b !important; }
.pele .note rect, .pele .note polygon, .pele .note circle {
  fill: #fafafa !important;
  stroke: #d4d4d8 !important;
  stroke-width: 1px !important;
}
.pele .note text { fill: #52525b !important; }
.pele .doubtPath rect, .pele .doubtPath polygon, .pele .doubtPath circle {
  stroke: #e72e3b !important;
  stroke-width: 2.5px !important;
}
.pele .open rect, .pele .open polygon, .pele .open circle,
.pele .axiom rect, .pele .axiom polygon, .pele .axiom circle,
.pele .restsOn rect, .pele .restsOn polygon, .pele .restsOn circle {
  fill: #fff3e6 !important;
  stroke: #e8730c !important;
  stroke-width: 2.5px !important;
}
.pele .open text, .pele .axiom text, .pele .restsOn text {
  fill: #b85a06 !important;
}
.pele .sorry rect, .pele .sorry polygon, .pele .sorry circle,
.pele .error rect, .pele .error polygon, .pele .error circle,
.pele .native rect, .pele .native polygon, .pele .native circle {
  fill: #ffecee !important;
  stroke: #e72e3b !important;
  stroke-width: 2.5px !important;
}
.pele .sorry text, .pele .error text, .pele .native text {
  fill: #cd2834 !important;
}
@media (prefers-color-scheme: dark) {
  .pele {
    --pele-bg: #1f1f1f;
    --pele-fg: #f5f5f5;
    --pele-muted: #acacac;
    --pele-line: #939393;
    --pele-surface: #121212;
    --pele-surface-alt: #2c2c2c;
    --pele-border: #4e4e4e;
  }
  .pele .blue rect { fill: #1b3857; }
  .pele .orange rect { fill: #573117; }
  .pele .purple rect { fill: #3c2e57; }
  .pele .yellow rect { fill: #573d17; }
  .pele .teal rect { fill: #174641; }
  .pele .tan rect { fill: #3d3127; }
  .pele .pink rect { fill: #57233e; }
  .pele .breaks rect {
    fill: #2e2021 !important;
    stroke: #cf2b35 !important;
  }
  .pele .breaks text {
    fill: #ff6463 !important;
  }
  .pele .mayBreak rect {
    fill: #2e2619 !important;
    stroke: #d0700f !important;
  }
  .pele .mayBreak text {
    fill: #ffa257 !important;
  }
  .pele .bugPath rect {
    stroke: #116dd2 !important;
  }
  .pele .repeats rect {
    stroke: #9a3fcf !important;
  }
  .pele .target rect, .pele .target polygon, .pele .target circle {
    fill: #172d47 !important;
    stroke: #4c9aff !important;
  }
  .pele .target text { fill: #9cc9ff !important; }
  .pele .goalRoot rect, .pele .goalRoot polygon, .pele .goalRoot circle {
    fill: #172d47 !important;
    stroke: #4c9aff !important;
  }
  .pele .goalRoot text { fill: #9cc9ff !important; }
  .pele .subRoot rect, .pele .subRoot polygon, .pele .subRoot circle {
    fill: #1e1b4b !important;
    stroke: #818cf8 !important;
  }
  .pele .subRoot text { fill: #c7d2fe !important; }
  .pele .termRoot rect, .pele .termRoot polygon, .pele .termRoot circle {
    fill: #134e4a !important;
    stroke: #2dd4bf !important;
  }
  .pele .termRoot text { fill: #99f6e4 !important; }
  .pele .closed rect, .pele .closed polygon, .pele .closed circle {
    fill: #153323 !important;
    stroke: #34d399 !important;
  }
  .pele .closed text { fill: #86efac !important; }
  .pele .folded rect, .pele .folded polygon, .pele .folded circle {
    fill: #2c1f4a !important;
    stroke: #a78bfa !important;
  }
  .pele .folded text { fill: #ddd6fe !important; }
  .pele .stub rect, .pele .stub polygon, .pele .stub circle {
    fill: #27272a !important;
    stroke: #a1a1aa !important;
  }
  .pele .stub text { fill: #d4d4d8 !important; }
  .pele .note rect, .pele .note polygon, .pele .note circle {
    fill: #262626 !important;
    stroke: #52525b !important;
  }
  .pele .note text { fill: #d4d4d8 !important; }
  .pele .doubtPath rect, .pele .doubtPath polygon, .pele .doubtPath circle {
    stroke: #cf2b35 !important;
  }
  .pele .open rect, .pele .open polygon, .pele .open circle,
  .pele .axiom rect, .pele .axiom polygon, .pele .axiom circle,
  .pele .restsOn rect, .pele .restsOn polygon, .pele .restsOn circle {
    fill: #2e2619 !important;
    stroke: #d0700f !important;
  }
  .pele .open text, .pele .axiom text, .pele .restsOn text {
    fill: #ffa257 !important;
  }
  .pele .sorry rect, .pele .sorry polygon, .pele .sorry circle,
  .pele .error rect, .pele .error polygon, .pele .error circle,
  .pele .native rect, .pele .native polygon, .pele .native circle {
    fill: #2e2021 !important;
    stroke: #cf2b35 !important;
  }
  .pele .sorry text, .pele .error text, .pele .native text {
    fill: #ff6463 !important;
  }
}
```
