Pest Formatter is a tool to format Pest grammar files.
bash
cargo install pest_fmt
Then use the pestfmt
command to format your .pest
files.
shell
pestfmt .
It will find all .pest
files in the current directory and format them.
Output:
```
2 files formatted. ```
Add pest_fmt
into your Cargo.toml
:
cargo add pest_fmt
Then use the Formatter
struct to format pest grammar.
```rust use pest_fmt::Formatter;
let mut fmt = Formatter::new("a={ASCIIDIGIT}"); let out = fmt.format().unwrap(); println!("{out}"); // a = { ASCIIDIGIT } ```
https://github.com/pest-parser/pest-ide-tools
Based on MacBook Pro (Apple M1 2020)
format (json.pest) time: [89.403 µs 89.632 µs 89.878 µs]
format (grammar.pest) time: [1.6018 ms 1.6054 ms 1.6105 ms]
Mozilla Public License 2.0