| 1 | <!-- |
| 2 | SPDX-FileCopyrightText: 2021 ilkecan <[email protected]> |
| 3 | |
| 4 | SPDX-License-Identifier: MPL-2.0 |
| 5 | --> |
| 6 | |
| 7 | # indent |
| 8 | |
| 9 | [](https://crates.io/crates/indent/) |
| 10 | [](https://www.mozilla.org/en-US/MPL/2.0/) |
| 11 | [](https://docs.rs/indent/) |
| 12 | [](https://libraries.io/cargo/indent) |
| 13 | [](https://github.com/XAMPPRocky/tokei) |
| 14 | [](https://api.reuse.software/info/git.sr.ht/~ilkecan/indent-rs) |
| 15 | |
| 16 | This crate provides 4 functions useful for inserting a multiline string into an |
| 17 | already indented context in another string: |
| 18 | |
| 19 | - `indent_by`: Indents every line that is not empty by the given number of spaces, |
| 20 | starting from the second line. |
| 21 | - `indent_with`: Indents every line that is not empty with the given prefix, |
| 22 | starting from the second line. |
| 23 | - `indent_all_by`: Indents every line that is not empty by the given number of spaces. |
| 24 | - `indent_all_with`: Indents every line that is not empty with the given prefix. |
| 25 | |
| 26 | ## Examples |
| 27 | ```rust |
| 28 | fn main() { |
| 29 | let string = "line one |
| 30 | |
| 31 | line two |
| 32 | "; |
| 33 | assert_eq!("line one\n\n line two\n", indent::indent_by(2, string)); |
| 34 | } |
| 35 | ``` |
| 36 | |
| 37 | ## License |
| 38 | [Mozilla Public License 2.0](LICENSE.txt) |
| 39 | |
| 40 | ## Contribution |
| 41 | Unless you explicitly state otherwise, any contribution intentionally submitted |
| 42 | for inclusion in the work by you shall be licensed under the Mozilla Public |
| 43 | License 2.0, without any additional terms or conditions. |