Text::Flow::Wrap(3pm)
β¨ Text::Flow::Wrap β¨
okay bestie, sit down, because we're talking about Text::Flow::Wrap β it's a Perl module (from the User Contributed Perl Documentation, if you care about the paperwork π
) and it does flexible word wrapping for not just ASCII output. yes. the wrapping works even when your fonts are doing the absolute most. π¦
πΈ SYNOPSIS πΈ
like, here's the vibe in code form:
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 how the second one is checking $pdf->get_text_width($_[0])? that's the whole point, she doesn't assume every character is one pixel wide. main character behavior fr fr. π
π DESCRIPTION π
so the whole purpose of this module β the moment, the reason she exists β is to give you text wrapping features without being tied down to ASCII based output and fixed-width fonts. no cap.
and why tho? because the author's needs were for sophisticated test control in PDF and GIF output formats in particular. yeah. PDFs. GIFs. the messy ones. π
β¨ METHODS β¨
π«Ά new (%params)
constructs a brand new Text::Flow::Wrap module, and the %params you hand her set the values of the attributes listed below. that's it, that's the constructor. iconic.
π«Ά wrap ($text)
this method accepts a bunch of text, and then returns a new string which is wrapped to the expected width. literally that's her job. give text, get text back but wrapped. slay.
π§ Attribute Accessors
π check_width (\&code)
okay so this one is required, and it must be a CODE reference β no shortcuts, bestie, she will notice. it's used to determine if the width of the text is appropriate. it gets, as an argument, a string which it should check the width of. it should return a Boolean value: true if the string has not exceeded the max width, and false if it has. π
π line_break ($str)
the line break character used when assembling and disassembling the text. defaults to the newline character "\n".
π paragraph_boundry ($str)
the paragraph boundry marker used when disassembling the text. defaults to the string "\n".
(yes it's spelled boundry in the attribute name. we don't fix her, we love her as she is π)
π paragraph_break ($str)
the paragraph breaker used when re-assembling the text. defaults to the string "\n\n".
π word_boundry ($str)
the word boundry marker used when disassembling the text. defaults to a single space character.
π word_break ($str)
the paragraph breaker used when re-assembling the text. defaults to a single space character.
π Paragraph Disassembling
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_paragraphs
π Paragraph Reassembling
these methods deal with putting the paragraph parts back together after the disassembling methods have done their work. πͺ
these methods are mostly used internally, but more sophisticated tools might need to access them as well (see Text::Flow)
reassemble_paragraphreassemble_paragraphs
π Introspection
π meta
returns the Moose meta object associated with this class. look at her, looking at herself. self-aware queen. β¨
π BUGS π
ngl, 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. don't suffer in silence bestie, report it. π«Ά
π AUTHOR π
Stevan Little <stevan@iinteractive.com>
π COPYRIGHT AND LICENSE π
Copyright 2007 by Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie β brought to you by perl v5.34.0, dated 2022-06-28. go wrap something cute. πβ¨π¦
π¦ where this page comes from
- debian bookworm: libtext-flow-perl 0.01-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtext-flow-perl 0.01-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtext-flow-perl 0.01-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtext-flow-perl 0.01-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtext-flow-perl 0.01-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms