Skip to content

Releases: mgeisler/textwrap

textwrap-0.16.1

17 Feb 16:35
39914e0
Compare
Choose a tag to compare

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.

  • #526: Ignore ANSI hyperlinks
    in display_width: calculations.
  • #521: Add Options::width
    setter method.
  • #520: Clarify that
    WordSeparator is an enum rather than a trait.
  • #518: Test with latest stable
    and nightly Rust, but check that we can build with Rust 1.56.

textwrap-0.15.2

24 Oct 15:51
Compare
Choose a tag to compare

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

23 Oct 19:40
3c052a0
Compare
Choose a tag to compare

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 as non_exhaustive. This will allow us to extend the struct in the future without breaking backwards compatibility.
  • #478: Add fast paths to fill and wrap. 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 and refill.
  • #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

15 Sep 21:46
Compare
Choose a tag to compare

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:

  • #448: Migrate to the Rust 2021 edition.
  • #458: Test with Rust 1.56 (first compiler release with support for Rust 2021).
  • #454: Make line endings configurable.
  • #467: Fix unfill and refill crashes.
  • #468: Fix refill to add back correct line ending.

textwrap-0.15.0

27 Feb 20:24
559e07a
Compare
Choose a tag to compare

Version 0.15.0 (2022-02-27)

This is a major feature release with two main changes:

  • #421: Use f64 instead of usize 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 as usize::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 and subsequent_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

27 Jun 07:23
Compare
Choose a tag to compare

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

26 Jun 21:31
f429594
Compare
Choose a tag to compare

Version 0.14.1 (2021-06-26)

This release fixes a panic reported by @makoto, thanks!

  • #391: Fix panic in find_words due to string access outside of a character boundary.

textwrap-0.14.0

05 Jun 08:19
65277f5
Compare
Choose a tag to compare

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 in indent.

    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

New Generic Parameters

  • #331: Remove outer boxing from Options.

  • #357: Replace core::WrapAlgorithm enum with a wrap_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 and WordSplitter traits to separate modules. Before, Textwrap had several top-level structs such as NoHyphenation and HyphenSplitter. These implementations of WordSplitter now lives in a dedicated word_splitters module. Similarly, we have a new word_separators module for implementations of WordSeparator.

  • #369: Rename Options::splitter to Options::word_splitter for consistency with the other fields backed by traits.

textwrap-0.13.4

23 Feb 21:41
c0a0db1
Compare
Choose a tag to compare

Version 0.13.4 (2021-02-23)

This release removes println! statements which was left behind in
unfill by mistake.

  • #296: Improve house
    building example with more comments.
  • #297: Remove debug
    prints in the new unfill function.

textwrap-0.13.3

20 Feb 19:01
ad143f1
Compare
Choose a tag to compare

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.

  • #276: Extend
    core::display_width to handle emojis when the unicode-width Cargo
    feature is disabled.
  • #279: Make indent
    preserve existing newlines in the input string.
  • #281: Ensure all
    Options fields have examples.
  • #282: Add a
    wrap_columns function.
  • #294: Add new
    unfill and refill functions.