redent
Strip redundant indentation and re-indent a string.
Removes the common leading indentation from a multi-line string, then indents it by a fixed
amount — handy for normalizing then re-formatting heredoc/template text. A faithful Rust port
of the widely-used redent npm package, built on
strip-indent and
indent-string.
#![no_std]- Differential-tested against the reference
redentimplementation
Install
[]
= "0.1"
Usage
use ;
// Strip the common indent (count defaults to 0):
assert_eq!;
// Strip, then re-indent by two spaces:
assert_eq!;
// Custom indent + indent empty lines:
assert_eq!;
Contributors ✨
This project follows the all-contributors specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the emoji key for how each contribution is recognized, and open a PR or issue to get involved.
Thanks goes to these wonderful people:
License
Licensed under either of MIT or Apache-2.0 at your option.