# ๐งฎ render_regex
**`render_regex`** is a static SVG rendering tool that visually represents the internal structure of a regular expression using the [`rusty_regex`](https://crates.io/crates/rusty_regex) engine.
It supports visualizing:
- ๐ Abstract Syntax Trees (AST)
- ๐ Non-deterministic Finite Automata (NFA)
- ๐ Deterministic Finite Automata (DFA)
Each visual stage is cleanly drawn as a `*.svg` and can be styled and laid out flexibly.
---
## ๐ง CLI Usage
cargo run -p render_regex -- '<regex>' [options]
### ๐ฏ Stage Options
You must either specify one stage or render all of them:
- `--stage <dfa|nfa|ast>`
Render one specific stage
- `--all`
Render all stages (`ast`, `nfa`, `dfa`)
### ๐ผ Layout Options
- `--layout <circle|tree|layeredbfs|forcedirected|radial>`
> Defaults per stage:
> โข AST โ `tree`
> โข NFA โ `layeredbfs`
> โข DFA โ `layeredbfs`
### ๐งพ Output Options
- `--output <filename.svg>`
File to save to (only with `--stage`)
- `--output-dir <dir>`
Directory for all outputs (default: `output/`)
- `--slug <text>`
Override sanitized filename slug for regex
### ๐คซ Logging / Feedback
- `--quiet`
Suppress standard logging
- `--print-paths`
Always print resolved output paths (even in quiet mode)
---
## ๐งช Examples
# All stages with default layout
cargo run -p render_regex -- 'a(b|c)*d'
# DFA only with a specific layout
cargo run -p render_regex -- 'a(b|c)*d' --stage dfa --layout layeredbfs
# Save to a specific file path
cargo run -p render_regex -- 'xyz' --stage ast --output diagram.svg
# Specify target output directory
cargo run -p render_regex -- 'abc*' --all --output-dir ./my_diagrams
# Slug override for filename
cargo run -p render_regex -- 'a(b|c)*d' --slug myregex
# Quiet mode but show file paths
cargo run -p render_regex -- 'a(b|c)*d' --quiet --print-paths