indent-string 0.1.0

Indent each line of a multi-line string. A faithful port of the indent-string npm package. Zero dependencies, no_std.
Documentation
# indent-string

[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)

[![crates.io](https://img.shields.io/crates/v/indent-string.svg)](https://crates.io/crates/indent-string)
[![docs.rs](https://docs.rs/indent-string/badge.svg)](https://docs.rs/indent-string)
[![CI](https://github.com/trananhtung/indent-string/actions/workflows/ci.yml/badge.svg)](https://github.com/trananhtung/indent-string/actions/workflows/ci.yml)
[![license](https://img.shields.io/crates/l/indent-string.svg)](#license)

**Indent each line of a multi-line string.**

`foo\nbar` → ` foo\n bar`. A faithful Rust port of the widely-used
[`indent-string`](https://www.npmjs.com/package/indent-string) npm package. The counterpart
of [`strip-indent`](https://crates.io/crates/strip-indent).

- **Zero dependencies**, **`#![no_std]`**
- Repeat count, custom indent string, and an `include_empty_lines` option
- Differential-tested against the reference `indent-string` implementation

## Install

```toml
[dependencies]
indent-string = "0.1"
```

## Usage

```rust
use indent_string::{indent_string, indent_string_with};

assert_eq!(indent_string("foo\nbar"), " foo\n bar");

// Repeat count + custom indent:
assert_eq!(indent_string_with("foo\nbar", 2, "\t", false), "\t\tfoo\n\t\tbar");

// By default, empty / whitespace-only lines are not indented:
assert_eq!(indent_string("foo\n\nbar"), " foo\n\n bar");

// ...unless you opt in:
assert_eq!(indent_string_with("foo\n\nbar", 1, " ", true), " foo\n \n bar");
```

A `count` of `0` returns the string unchanged. Indentation is applied after every JavaScript
line terminator (`\n`, `\r`, `\u{2028}`, `\u{2029}`), matching the reference's `/^/gm`.

## Contributors ✨

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the [emoji key](https://allcontributors.org/docs/en/emoji-key) for how each contribution is recognized, and open a PR or issue to get involved.

Thanks goes to these wonderful people:

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
  <tbody>
    <tr>
      <td align="center" valign="top" width="14.28%"><a href="https://github.com/trananhtung"><img src="https://avatars.githubusercontent.com/u/30992229?v=4?s=100" width="100px;" alt="Tung Tran"/><br /><sub><b>Tung Tran</b></sub></a><br /><a href="https://github.com/trananhtung/./commits?author=trananhtung" title="Code">💻</a> <a href="#maintenance-trananhtung" title="Maintenance">🚧</a></td>
    </tr>
  </tbody>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

## License

Licensed under either of [MIT](LICENSE-MIT) or [Apache-2.0](LICENSE-APACHE) at your option.