Releases: mgeisler/textwrap
textwrap-0.16.1
Version 0.16.1 (2024-02-17)
This release fixes display_width
to ignore inline-hyperlinks. The minimum
supported version of Rust is now documented to be 1.56.
textwrap-0.15.2
Version 0.15.2 (2022-10-24)
This release is identical to 0.15.0 and is only there to give people a way to install crates which depend on the yanked 0.15.1 release. See #484 for details.
textwrap-0.16.0
Version 0.16.0 (2022-10-23)
This release marks Options
as non_exhaustive
and extends it to make line endings configurable, it adds new fast paths to fill
and wrap
, and it fixes crashes in unfill
and refill
.
- #480: Mark
Options
asnon_exhaustive
. This will allow us to extend the struct in the future without breaking backwards compatibility. - #478: Add fast paths to
fill
andwrap
. This makes the functions 10-25 times faster when the no wrapping is needed. - #468: Fix
refill
to add back correct line ending. - #467: Fix crashes in
unfill
andrefill
. - #458: Test with Rust 1.56 (first compiler release with support for Rust 2021).
- #454: Make line endings configurable.
- #448: Migrate to the Rust 2021 edition.
textwrap-0.15.1
Version 0.15.1 (2022-09-15)
This release which fixes crashes in unfill
and refill
. It also adds a new option to make the line endings (\n
or \r\n
) configurable:
textwrap-0.15.0
Version 0.15.0 (2022-02-27)
This is a major feature release with two main changes:
-
#421: Use
f64
instead ofusize
for fragment widths.This fixes problems with overflows in the internal computations of
wrap_optimal_fit
when fragments (words) or line lengths had extreme values, such asusize::MAX
. -
#438: Simplify
Options
by removing generic type parameters.This change removes the new generic parameters introduced in version 0.14, as well as the original
WrapSplitter
parameter which has been present since very early versions.The result is a simplification of function and struct signatures across the board. So what used to be
let options: Options< wrap_algorithms::FirstFit, word_separators::AsciiSpace, word_splitters::HyphenSplitter, > = Options::new(80);
if types are fully written out, is now simply
let options: Options<'_> = Options::new(80);
The anonymous lifetime represent the lifetime of the
initial_indent
andsubsequent_indent
strings. The change is nearly performance neutral (a 1-2% regression).
Smaller improvements and changes:
- #404: Make documentation for short last-line penalty more precise.
- #405: Cleanup and simplify
Options
docstring. - #411: Default to
OptimalFit
in interactive example. - #415: Add demo program to help compute binary sizes.
- #423: Add fuzz tests with fully arbitrary fragments.
- #424: Change
wrap_optimal_fit
penalties to non-negative numbers. - #430: Add
debug-words
example. - #432: Use precise dependency versions in Cargo.toml.
textwrap-0.14.2
Version 0.14.2 (2021-06-27)
The 0.14.1 release included more changes than intended and has been yanked. The change intended for 0.14.1 is now included in 0.14.2.
textwrap-0.14.1
textwrap-0.14.0
Version 0.14.0 (2021-06-05)
This is a major feature release which makes Textwrap more configurable and flexible. The high-level API of textwrap::wrap
and textwrap::fill
remains unchanged, but low-level structs have moved around.
The biggest change is the introduction of new generic type parameters to the Options
struct. These parameters lets you statically configure the wrapping algorithm, the word separator, and the word splitter. If you previously spelled out the full type for Options
, you now need to take the extra type parameters into account. This means that
let options: Options<HyphenSplitter> = Options::new(80);
changes to
let options: Options<
wrap_algorithms::FirstFit,
word_separators::AsciiSpace,
word_splitters::HyphenSplitter,
> = Options::new(80);
This is quite a mouthful, so we suggest using type inferrence where possible. You won’t see any chance if you call wrap
directly with a width or with an Options
value constructed on the fly. Please open an issue if this causes problems for you!
New WordSeparator
Trait
-
#332: Add
WordSeparator
trait to allow customizing how words are found in a line of text. Until now, Textwrap would always assume that words are separated by ASCII space characters. You can now customize this as needed. -
#313: Add support for using the Unicode line breaking algorithm to find words. This is done by adding a second implementation of the new
WordSeparator
trait. The implementation uses the unicode-linebreak crate, which is a new optional dependency.With this, Textwrap can be used with East-Asian languages such as Chinese or Japanese where there are no spaces between words. Breaking a long sequence of emojis is another example where line breaks might be wanted even if there are no whitespace to be found. Feedback would be appreciated for this feature.
Indent
-
#353: Trim trailing whitespace from
prefix
inindent
.Before, empty lines would get no prefix added. Now, empty lines have a trimmed prefix added. This little trick makes
indent
much more useful since you can now safely indent with"# "
without creating trailing whitespace in the output due to the trailing whitespace in your prefix. -
#354: Make
indent
about 20% faster by preallocating the output string.
Documentation
- #308: Document handling of leading and trailing whitespace when wrapping text.
WebAssembly Demo
- #310: Thanks to WebAssembly, you can now try out Textwrap directly in your browser: https://mgeisler.github.io/textwrap/.
New Generic Parameters
-
#331: Remove outer boxing from
Options
. -
#357: Replace
core::WrapAlgorithm
enum with awrap_algorithms::WrapAlgorithm
trait. This allows for arbitrary wrapping algorithms to be plugged into the library. -
#358: Switch wrapping functions to use a slice for
line_widths
. -
#368: Move
WordSeparator
andWordSplitter
traits to separate modules. Before, Textwrap had several top-level structs such asNoHyphenation
andHyphenSplitter
. These implementations ofWordSplitter
now lives in a dedicatedword_splitters
module. Similarly, we have a newword_separators
module for implementations ofWordSeparator
. -
#369: Rename
Options::splitter
toOptions::word_splitter
for consistency with the other fields backed by traits.
textwrap-0.13.4
textwrap-0.13.3
Version 0.13.3 (2021-02-20)
This release contains a bugfix for indent
and improved handling of
emojis. We’ve also added a new function for formatting text in columns
and functions for reformatting already wrapped text.