1Text::LineFold(3) User Contributed Perl Documentation Text::LineFold(3)
2
3
4
6 Text::LineFold - Line Folding for Plain Text
7
9 use Text::LineFold;
10 $lf = Text::LineFold->new();
11
12 # Fold lines
13 $folded = $lf->fold($string, 'PLAIN');
14 $indented = $lf->fold(' ' x 8, ' ' x 4, $string);
15
16 # Unfold lines
17 $unfolded = $lf->unfold($string, 'FIXED');
18
20 Text::LineFold folds or unfolds lines of plain text. As it mainly
21 focuses on plain text e-mail messages, RFC 3676 flowed format is also
22 supported.
23
24 Public Interface
25 new ([KEY => VALUE, ...])
26 Constructor. About KEY => VALUE pairs see config method.
27
28 $self->config (KEY)
29 $self->config ([KEY => VAL, ...])
30 Instance method. Get or update configuration. Following KEY =>
31 VALUE pairs may be specified.
32
33 Charset => CHARSET
34 Character set that is used to encode string. It may be string
35 or MIME::Charset object. Default is "UTF-8".
36
37 Language => LANGUAGE
38 Along with Charset option, this may be used to define
39 language/region context. Default is "XX". See also "Context"
40 in Unicode::LineBreak option.
41
42 Newline => STRING
43 String to be used for newline sequence. Default is "\n".
44
45 OutputCharset => CHARSET
46 Character set that is used to encode result of fold()/unfold().
47 It may be string or MIME::Charset object. If a special value
48 "_UNICODE_" is specified, result will be Unicode string.
49 Default is the value of Charset option.
50
51 TabSize => NUMBER
52 Column width of tab stops. When 0 is specified, tab stops are
53 ignored. Default is 8.
54
55 BreakIndent
56 CharMax
57 ColMax
58 ColMin
59 ComplexBreaking
60 EAWidth
61 HangulAsAL
62 LBClass
63 LegacyCM
64 Prep
65 Urgent
66 See "Options" in Unicode::LineBreak.
67
68 $self->fold (STRING, [METHOD])
69 $self->fold (INITIAL_TAB, SUBSEQUENT_TAB, STRING, ...)
70 Instance method. fold() folds lines of string STRING and returns
71 it. Surplus SPACEs and horizontal tabs at end of line are removed,
72 newline sequences are replaced by that specified by Newline option
73 and newline is appended at end of text if it does not exist.
74 Horizontal tabs are treated as tab stops according to TabSize
75 option.
76
77 By the first style, following options may be specified for METHOD
78 argument.
79
80 "FIXED"
81 Lines preceded by ">" won't be folded. Paragraphs are
82 separated by empty line.
83
84 "FLOWED"
85 "Format=Flowed; DelSp=Yes" formatting defined by RFC 3676.
86
87 "PLAIN"
88 Default method. All lines are folded.
89
90 Second style is similar to "wrap()" in Text::Wrap. All lines are
91 folded. INITIAL_TAB is inserted at beginning of paragraphs and
92 SUBSEQUENT_TAB at beginning of other broken lines.
93
94 $self->unfold (STRING, METHOD)
95 Conjunct folded paragraphs of string STRING and returns it.
96
97 Following options may be specified for METHOD argument.
98
99 "FIXED"
100 Default method. Lines preceded by ">" won't be conjuncted.
101 Treat empty line as paragraph separator.
102
103 "FLOWED"
104 Unfold "Format=Flowed; DelSp=Yes" formatting defined by RFC
105 3676.
106
107 "FLOWEDSP"
108 Unfold "Format=Flowed; DelSp=No" formatting defined by RFC
109 3676.
110
112 Please report bugs or buggy behaviors to developer.
113
114 CPAN Request Tracker:
115 <http://rt.cpan.org/Public/Dist/Display.html?Name=Unicode-LineBreak>.
116
118 Consult $VERSION variable.
119
121 Unicode::LineBreak, Text::Wrap.
122
124 Copyright (C) 2009-2012 Hatuka*nezumi - IKEDA Soji
125 <hatuka(at)nezumi.nu>.
126
127 This program is free software; you can redistribute it and/or modify it
128 under the same terms as Perl itself.
129
130
131
132perl v5.32.1 2021-01-27 Text::LineFold(3)