logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Text::Flow::Wrap - Flexible word wrapping for not just ASCII output.

Author

       Stevan Little <stevan@iinteractive.com>

Bugs

       All  complex  software  has bugs lurking in it, and this module is no exception. If you find a bug please
       either email me, or add the bug to cpan-RT.

Description

       The main purpose of this module is to provide text wrapping features without being tied down to ASCII
       based output and fixed-width fonts.

       My needs were for sophisticated test control in PDF and GIF output formats in particular.

Methods

new(%params)
           This  constructs  a new Text::Flow::Wrap module whose %params set the values of the attributes listed
           below.

       wrap($text)
           This method will accept a bunch of text, it will then return a new string which  is  wrapped  to  the
           expected width.

   AttributeAccessorscheck_width(\&code)
           This attribute is required, and must be a CODE reference. This will be used to determine if the width
           of  the text is appropriate. It will get as an argument, a string which is should check the width of.
           It should return a Boolean value, true if the string is not exceeded the max width and  false  if  it
           has.

       line_break($str)
           This  is the line break character used when assembling and disassembling the text, it defaults to the
           newline character "\n".

       paragraph_boundry($str)
           This is the paragraph boundry marker used when disassembling the text,  it  defaults  to  the  string
           "\n".

       paragraph_break($str)
           This is the paragraph breaker used when re-assembling the text, it defaults to the string "\n\n".

       word_boundry($str)
           This  is  the  word  boundry  marker  used when disassembling the text, it defaults to a single space
           character.

       word_break($str)
           This is the paragraph breaker used when re-assembling  the  text,  it  defaults  to  a  single  space
           character.

   ParagraphDisassembling
       These  methods  deal  with breaking up the paragraphs into its parts, which can then be processed through
       the re-assembling methods.

       These methods are mostly used internally, but more sophisticated tools might need to access them as  well
       (see Text::Flow).

       disassemble_paragraphdisassemble_paragraphsParagraphReassembling
       These  methods  deal  with putting the paragraph parts back together after the disassembling methods have
       done thier work.

       These methods are mostly used internally, but more sophisticated tools might need to access them as  well
       (see Text::Flow)

       reassemble_paragraphreassemble_paragraphsIntrospectionmeta
           Returns the Moose meta object associated with this class.

Name

       Text::Flow::Wrap - Flexible word wrapping for not just ASCII output.

Synopsis

         use Text::Flow::Wrap;

         # for regular ASCII usage ...
         my $wrapper = Text::Flow::Wrap->new(
             check_width => sub { length($_[0]) < 70 },
         );

         # for non-ASCII usage ...
         my $wrapper = Text::Flow::Wrap->new(
             check_width => sub { $pdf->get_text_width($_[0]) < 500 },
         );

         my $text = $wrapper->wrap($text);

See Also