#extensible #language #formatter #prettier #format #formatting #ast

prettify

An extensible, language-agnostic code formatter based on Prettier written in Rust

4 releases (2 breaking)

0.3.0 Jul 18, 2022
0.2.1 Jun 29, 2022
0.2.0 Jun 26, 2022
0.1.0 Jun 13, 2022

#3 in #prettier


Used in prettify-markdown

MIT license

35KB
857 lines

Prettify

An extensible, language-agnostic code formatter based on Prettier written in Rust.

The goal of this library is to provide a simple, fast, and extensible way to format code. Instead of formatting code for any specific language, it's language agnostic by accepting an intermediate representation instead of an AST.

That way, you can format code at the speed of Rust.

Prettify is in beta. I believe it's feature complete and there are no bugs in this library. However, this library does not yet have 100% end-to-end test coverage, so it is possible there are bugs. Please file an issue if you find a bug.


This library is simply the core algorithm for Prettify. The actual parsing of each of different languages are in their own crates:

This library is distributed as it's own crate in case you wish to use it in your own project or for your own language. That way you can simply describe how your language should be formatted and let Prettify take care of the rest!

Dependencies

~2.1–3MB
~53K SLoC