Text::LineFold(3)

πŸ’– NAME πŸ’–

Text::LineFold β€” Line Folding for Plain Text ✨ (manual page Text::LineFold(3), hiiii πŸ’…)

✨ SYNOPSIS ✨

use Text::LineFold;
$lf = Text::LineFold->new();

# Fold lines
$folded = $lf->fold($string, 'PLAIN');
$indented = $lf->fold(' ' x 8, ' ' x 4, $string);

# Unfold lines
$unfolded = $lf->unfold($string, 'FIXED');

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so Text::LineFold folds or unfolds lines of plain text. It mainly focuses on plain text e-mail messages, and RFC 3676 flowed format is also supported. It’s giving very specific niche icon behavior, and honestly? Obsessed. πŸ’–

🫢 Public Interface 🫢

🌸 new ([KEY => VALUE, ...]) 🌸

Constructor. For the tea on KEY => VALUE pairs, see the config method. 🫢

πŸŽ€ $self->config (KEY) / $self->config ([KEY => VAL, ...]) πŸŽ€

Instance method. Get or update configuration. Following KEY => VALUE pairs may be specified:

  • Charset => CHARSET β€” character set used to encode string. It may be a string or a MIME::Charset object. Default is "UTF-8".
  • Language => LANGUAGE β€” along with the Charset option, this may be used to define language/region context. Default is "XX". See also "Context" in Unicode::LineBreak option.
  • Newline => STRING β€” string to be used for newline sequence. Default is "\n".
  • OutputCharset => CHARSET β€” character set used to encode result of fold()/unfold(). It may be a string or a MIME::Charset object. If a special value "_UNICODE_" is specified, result will be Unicode string. Default is the value of Charset option.
  • TabSize => NUMBER β€” column width of tab stops. When 0 is specified, tab stops are ignored. Default is 8.
  • BreakIndent β€” see "Options" in Unicode::LineBreak.
  • CharMax β€” see "Options" in Unicode::LineBreak.
  • ColMax β€” see "Options" in Unicode::LineBreak.
  • ColMin β€” see "Options" in Unicode::LineBreak.
  • ComplexBreaking β€” see "Options" in Unicode::LineBreak.
  • EAWidth β€” see "Options" in Unicode::LineBreak.
  • HangulAsAL β€” see "Options" in Unicode::LineBreak.
  • LBClass β€” see "Options" in Unicode::LineBreak.
  • LegacyCM β€” see "Options" in Unicode::LineBreak.
  • Prep β€” see "Options" in Unicode::LineBreak.
  • Urgent β€” see "Options" in Unicode::LineBreak.

πŸ¦‹ $self->fold (STRING, [METHOD]) / $self->fold (INITIAL_TAB, SUBSEQUENT_TAB, STRING, ...) πŸ¦‹

Instance method. fold() folds lines of string STRING and returns it. Surplus SPACEs and horizontal tabs at end of line are removed, newline sequences are replaced by that specified by Newline option and newline is appended at end of text if it does not exist. Horizontal tabs are treated as tab stops according to TabSize option.

By the first style, following options may be specified for METHOD argument.

  • "FIXED" β€” lines preceded by ">" won’t be folded. Paragraphs are separated by empty line.
  • "FLOWED" β€” "Format=Flowed; DelSp=Yes" formatting defined by RFC 3676.
  • "PLAIN" β€” default method. All lines are folded.

Second style is similar to "wrap()" in Text::Wrap. All lines are folded. INITIAL_TAB is inserted at beginning of paragraphs and SUBSEQUENT_TAB at beginning of other broken lines. Slay. πŸ’…

🧚 $self->unfold (STRING, METHOD) 🧚

Conjunct folded paragraphs of string STRING and returns it.

Following options may be specified for METHOD argument.

  • "FIXED" β€” default method. Lines preceded by ">" won’t be conjuncted. Treat empty line as paragraph separator.
  • "FLOWED" β€” unfold "Format=Flowed; DelSp=Yes" formatting defined by RFC 3676.
  • "FLOWEDSP" β€” unfold "Format=Flowed; DelSp=No" formatting defined by RFC 3676.

πŸ’€ BUGS πŸ’€

Please report bugs or buggy behaviors to developer.

CPAN Request Tracker:
<http://rt.cpan.org/Public/Dist/Display.html?Name=Unicode-LineBreak>.

🌈 VERSION 🌈

Consult $VERSION variable.

πŸ‘‘ SEE ALSO πŸ‘‘

Unicode::LineBreak, Text::Wrap.

πŸŽ€ AUTHOR πŸŽ€

Copyright (C) 2009-2012 Hatuka*nezumi - IKEDA Soji
<hatuka(at)nezumi.nu>.

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


πŸ’– Okay bestie, that’s the whole page β€” from User Contributed Perl Documentation, perl v5.42.0, dated 2018-12-29. Stay folded, stay iconic, periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from