| Crates.io | pest_fmt |
| lib.rs | pest_fmt |
| version | 0.2.5 |
| created_at | 2020-02-06 15:03:19.003852+00 |
| updated_at | 2024-03-22 02:04:07.638267+00 |
| description | A formatter tool for pest |
| homepage | |
| repository | https://github.com/pest-parser/pest-fmt |
| max_upload_size | |
| id | 205501 |
| size | 188,979 |
Pest Formatter is a tool to format Pest grammar files.
cargo install pest_fmt
Then use the pestfmt command to format your .pest files.
$ pestfmt -h
A formatter tool for pest
Usage: pestfmt [OPTIONS] [FILE]...
Arguments:
[FILE]... The file or path to format [default: .]
Options:
-s, --stdin
-h, --help Print help
-V, --version Print version
$ pestfmt .
It will find all .pest files in the current directory and format and overwrite them.
Output:
Pest Formatter
-------------------------------------
2 files formatted.
You can use --stdin option to format Pest source code from stdin, it will read from stdin and write to stdout.
cat file.pest | pestfmt --stdin
Add pest_fmt into your Cargo.toml:
$ cargo add pest_fmt
Then use the Formatter struct to format pest grammar.
use pest_fmt::Formatter;
let mut fmt = Formatter::new("a={ASCII_DIGIT}");
let out = fmt.format().unwrap();
println!("{out}");
// a = { ASCII_DIGIT }
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