Skip to content

stsc/Text-Wrap-Smart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME
    Text::Wrap::Smart - Wrap text into chunks of similar length

SYNOPSIS
     use Text::Wrap::Smart ':all';
     # or
     use Text::Wrap::Smart qw(exact_wrap fuzzy_wrap);

     @chunks = exact_wrap($text, $wrap_at);
     @chunks = fuzzy_wrap($text, $wrap_at);

DESCRIPTION
    "Text::Wrap::Smart" is the pure perl companion of
    "Text::Wrap::Smart::XS".

FUNCTIONS
  exact_wrap
     @chunks = exact_wrap($text [, $wrap_at ]);

    Wrap a text of varying length into exact chunks (except the last one,
    which consists of the remaining text).

    Optionally a wrapping length may be specified; if no length is supplied,
    a default of 160 will be assumed.

  fuzzy_wrap
     @chunks = fuzzy_wrap($text [, $wrap_at ]);

    Wrap a text of varying length into chunks of fuzzy length (the boundary
    is normally calculated from the last whitespace preceding the wrapping
    length, and if no remaining whitespace could be found the end of text;
    if the wrapping length is smaller than the size of a word, greedy
    wrapping will be applied: all characters until the first whitespace
    encountered form a chunk).

    Optionally a wrapping length may be specified; if no length is supplied,
    a default of 160 will be assumed.

EXPORT
  Functions
    "exact_wrap(), fuzzy_wrap()" are exportable.

  Tags
    ":all - *()"

BUGS & CAVEATS
    The wrapping length will not be applied directly, but is used to
    calculate the average length to split text into chunks.

    Text will be normalized prior to being processed, i.e. leading and
    trailing whitespace will be chopped off before each remaining whitespace
    is converted to a literal space.

SEE ALSO
    Text::Wrap, Text::Wrap::Smart::XS

AUTHOR
    Steven Schubiger <schubiger@cpan.org>

LICENSE
    This program is free software; you may redistribute it and/or modify it
    under the same terms as Perl itself.

    See <http://dev.perl.org/licenses/>

About

Wrap text into chunks of similar length

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages