diff --git a/README.md b/README.md index 791f25b5..39093e08 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,15 @@ [![](https://img.shields.io/crates/v/textwrap.svg)][crates-io] [![](https://docs.rs/textwrap/badge.svg)][api-docs] -Textwrap is a library for word wrapping text. You can use it to format -strings for display in commandline applications. The crate name and -interface is inspired by the [Python textwrap module][py-textwrap]. +Textwrap is a library for wrapping and indenting text. It is most +often used by command-line programs to format dynamic output nicely so +it looks good in a terminal. However, you can use the library to wrap +arbitrary things by implementing the `Fragment` trait — an example +would be wrapping text for PDF files. ## Usage -To use `textwrap`, add this to your `Cargo.toml` file: +To use the textwrap crate, add this to your `Cargo.toml` file: ```toml [dependencies] textwrap = "0.13" @@ -23,7 +25,7 @@ Unicode support can be disabled if needed. This allows you slim down the library and so you will only pay for the features you actually use. Please see the [_Cargo Features_ in the crate documentation](https://docs.rs/textwrap/#cargo-features) for a full -list of the featurs. +list of the available features. ## Documentation @@ -56,7 +58,7 @@ The explanation is that textwrap does not just wrap text one line at a time. Instead, it uses an optimal-fit algorithm which looks ahead and chooses line breaks which minimize the gaps left at ends of lines. -Without look ahead, the first line would be longer and the text would +Without look-ahead, the first line would be longer and the text would look like this: ``` @@ -106,7 +108,6 @@ see the [`hyphenation` documentation] for details. If your strings are known at compile time, please take a look at the procedural macros from the [`textwrap-macros` crate]. - ## Examples The library comes with [a @@ -141,7 +142,6 @@ Contributions will be accepted under the same license. [crates-io]: https://crates.io/crates/textwrap [build-status]: https://github.com/mgeisler/textwrap/actions?query=workflow%3Abuild+branch%3Amaster [codecov]: https://codecov.io/gh/mgeisler/textwrap -[py-textwrap]: https://docs.python.org/library/textwrap [`textwrap-macros` crate]: https://crates.io/crates/textwrap-macros [`hyphenation` example]: https://github.com/mgeisler/textwrap/blob/master/examples/hyphenation.rs [`termwidth` example]: https://github.com/mgeisler/textwrap/blob/master/examples/termwidth.rs diff --git a/src/core.rs b/src/core.rs index 22237f34..629f3c11 100644 --- a/src/core.rs +++ b/src/core.rs @@ -453,8 +453,7 @@ pub enum WrapAlgorithm { /// "not wrap", /// "nicely."]); /// -/// // We can avoid the short line if we look ahead (this requires the -/// // smawk Cargo feature): +/// // We can avoid the short line if we look ahead: /// #[cfg(feature = "smawk")] /// assert_eq!(lines_to_strings(textwrap::core::wrap_optimal_fit(&words, |_| 15)), /// vec!["These few", diff --git a/src/lib.rs b/src/lib.rs index 67fcb19e..e3d83cb4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,8 @@ //! The textwrap library provides functions for word wrapping and -//! filling text. +//! indenting text. //! -//! Wrapping text can be very useful in commandline programs where you -//! want to format dynamic output nicely so it looks good in a +//! Wrapping text can be very useful in command-line programs where +//! you want to format dynamic output nicely so it looks good in a //! terminal. A quick example: //! //! ```no_run