Debian Codegraph @

upstream/mageia-cauldron/man3pm/Term::Table.3pm

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "Term::Table 3pm"
61 .TH Term::Table 3pm 2025-06-24 "perl v5.42.0" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 Term::Table \- Format a header and rows into a table
68 .SH DESCRIPTION
69 .IX Header "DESCRIPTION"
70 This is used by some failing tests to provide diagnostics about what has gone
71 wrong. This module is able to format rows of data into tables.
72 .SH SYNOPSIS
73 .IX Header "SYNOPSIS"
74 .Vb 1
75 \& use Term::Table;
76 \&
77 \& my $table = Term::Table\->new(
78 \& max_width => 80, # Defaults to terminal size
79 \& pad => 4, # Extra padding between table and max\-width (defaults to 4)
80 \& allow_overflow => 0, # Default is 0, when off an exception will be thrown if the table is too big
81 \& collapse => 1, # Do not show empty columns
82 \&
83 \& header => [\*(Aqname\*(Aq, \*(Aqage\*(Aq, \*(Aqhair color\*(Aq],
84 \& rows => [
85 \& [\*(AqFred Flintstone\*(Aq, 2000000, \*(Aqblack\*(Aq],
86 \& [\*(AqWilma Flintstone\*(Aq, 1999995, \*(Aqred\*(Aq],
87 \& ...
88 \& ],
89 \& );
90 \&
91 \& say $_ for $table\->render;
92 .Ve
93 .PP
94 This prints a table like this:
95 .PP
96 .Vb 7
97 \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+
98 \& | name | age | hair color |
99 \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+
100 \& | Fred Flintstone | 2000000 | black |
101 \& | Wilma Flintstone | 1999995 | red |
102 \& | ... | ... | ... |
103 \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+
104 .Ve
105 .SH INTERFACE
106 .IX Header "INTERFACE"
107 .Vb 2
108 \& use Term::Table;
109 \& my $table = Term::Table\->new(...);
110 .Ve
111 .SS OPTIONS
112 .IX Subsection "OPTIONS"
113 .IP "header => [ ... ]" 4
114 .IX Item "header => [ ... ]"
115 If you want a header specify it here.
116 This takes an arrayref with each columns heading.
117 .IP "rows => [ [...], [...], ... ]" 4
118 .IX Item "rows => [ [...], [...], ... ]"
119 This should be an arrayref containing an arrayref per row.
120 .ie n .IP "collapse => $bool" 4
121 .el .IP "collapse => \f(CW$bool\fR" 4
122 .IX Item "collapse => $bool"
123 Use this if you want to hide empty columns, that is any column that has no data
124 in any row. Having a header for the column will not effect collapse.
125 .ie n .IP "max_width => $num" 4
126 .el .IP "max_width => \f(CW$num\fR" 4
127 .IX Item "max_width => $num"
128 Set the maximum width of the table, the table may not be this big, but it will
129 be no bigger. If none is specified it will attempt to find the width of your
130 terminal and use that, otherwise it falls back to the terminal width or \f(CW80\fR.
131 .ie n .IP "pad => $num" 4
132 .el .IP "pad => \f(CW$num\fR" 4
133 .IX Item "pad => $num"
134 Defaults to \f(CW4\fR, extra padding for row width calculations.
135 Default is for legacy support.
136 Set this to \f(CW0\fR to turn padding off.
137 .ie n .IP "allow_overflow => $bool" 4
138 .el .IP "allow_overflow => \f(CW$bool\fR" 4
139 .IX Item "allow_overflow => $bool"
140 Defaults to \f(CW0\fR. If this is off then an exception will be thrown if the table
141 cannot be made to fit inside the max\-width. If this is set to \f(CW1\fR then the
142 table will be rendered anyway, larger than max\-width, if it is not possible
143 to stay within the max\-width. In other words this turns max\-width from a
144 hard\-limit to a soft recommendation.
145 .ie n .IP "sanitize => $bool" 4
146 .el .IP "sanitize => \f(CW$bool\fR" 4
147 .IX Item "sanitize => $bool"
148 This will sanitize all the data in the table such that newlines, control
149 characters, and all whitespace except for ASCII 20 \f(CW\*(Aq \*(Aq\fR are replaced with
150 escape sequences. This prevents newlines, tabs, and similar whitespace from
151 disrupting the table.
152 .Sp
153 \&\fBNote:\fR newlines are marked as \f(CW\*(C`\en\*(C'\fR, but a newline is also inserted into the
154 data so that it typically displays in a way that is useful to humans.
155 .Sp
156 Example:
157 .Sp
158 .Vb 1
159 \& my $field = "foo\enbar\enbaz\en";
160 \&
161 \& print join "\en" => table(
162 \& sanitize => 1,
163 \& rows => [
164 \& [$field, \*(Aqcol2\*(Aq ],
165 \& [\*(Aqrow2 col1\*(Aq, \*(Aqrow2 col2\*(Aq]
166 \& ]
167 \& );
168 .Ve
169 .Sp
170 Prints:
171 .Sp
172 .Vb 7
173 \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
174 \& | foo\en | col2 |
175 \& | bar\en | |
176 \& | baz\en | |
177 \& | | |
178 \& | row2 col1 | row2 col2 |
179 \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
180 .Ve
181 .Sp
182 So it marks the newlines by inserting the escape sequence, but it also shows
183 the data across as many lines as it would normally display.
184 .ie n .IP "mark_tail => $bool" 4
185 .el .IP "mark_tail => \f(CW$bool\fR" 4
186 .IX Item "mark_tail => $bool"
187 This will replace the last whitespace character of any trailing whitespace with
188 its escape sequence. This makes it easier to notice trailing whitespace when
189 comparing values.
190 .ie n .IP "show_header => $bool" 4
191 .el .IP "show_header => \f(CW$bool\fR" 4
192 .IX Item "show_header => $bool"
193 Set this to false to hide the header. This defaults to true if the header is
194 set, false if no header is provided.
195 .ie n .IP "auto_columns => $bool" 4
196 .el .IP "auto_columns => \f(CW$bool\fR" 4
197 .IX Item "auto_columns => $bool"
198 Set this to true to automatically add columns that are not named in the header.
199 This defaults to false if a header is provided, and defaults to true when there
200 is no header.
201 .ie n .IP "no_collapse => [ $col_num_a, $col_num_b, ... ]" 4
202 .el .IP "no_collapse => [ \f(CW$col_num_a\fR, \f(CW$col_num_b\fR, ... ]" 4
203 .IX Item "no_collapse => [ $col_num_a, $col_num_b, ... ]"
204 .PD 0
205 .ie n .IP "no_collapse => [ $col_name_a, $col_name_b, ... ]" 4
206 .el .IP "no_collapse => [ \f(CW$col_name_a\fR, \f(CW$col_name_b\fR, ... ]" 4
207 .IX Item "no_collapse => [ $col_name_a, $col_name_b, ... ]"
208 .ie n .IP "no_collapse => { $col_num_a => 1, $col_num_b => 1, ... }" 4
209 .el .IP "no_collapse => { \f(CW$col_num_a\fR => 1, \f(CW$col_num_b\fR => 1, ... }" 4
210 .IX Item "no_collapse => { $col_num_a => 1, $col_num_b => 1, ... }"
211 .ie n .IP "no_collapse => { $col_name_a => 1, $col_name_b => 1, ... }" 4
212 .el .IP "no_collapse => { \f(CW$col_name_a\fR => 1, \f(CW$col_name_b\fR => 1, ... }" 4
213 .IX Item "no_collapse => { $col_name_a => 1, $col_name_b => 1, ... }"
214 .PD
215 Specify (by number and/or name) columns that should not be removed when empty.
216 The \*(Aqname\*(Aq form only works when a header is specified. There is currently no
217 protection to insure that names you specify are actually in the header, invalid
218 names are ignored, patches to fix this will be happily accepted.
219 .SH "NOTE ON UNICODE/WIDE CHARACTERS"
220 .IX Header "NOTE ON UNICODE/WIDE CHARACTERS"
221 Some unicode characters, such as \f(CW\*(C`婧\*(C'\fR (\f(CW\*(C`U+5A67\*(C'\fR) are wider than others. These
222 will render just fine if you \f(CW\*(C`use utf8;\*(C'\fR as necessary, and
223 Unicode::GCString is installed, however if the module is not installed there
224 will be anomalies in the table:
225 .PP
226 .Vb 7
227 \& +\-\-\-\-\-+\-\-\-\-\-+\-\-\-+
228 \& | a | b | c |
229 \& +\-\-\-\-\-+\-\-\-\-\-+\-\-\-+
230 \& | 婧 | x | y |
231 \& | x | y | z |
232 \& | x | 婧 | z |
233 \& +\-\-\-\-\-+\-\-\-\-\-+\-\-\-+
234 .Ve
235 .SH SOURCE
236 .IX Header "SOURCE"
237 The source code repository for \f(CW\*(C`Term\-Table\*(C'\fR can be found at
238 <https://github.com/exodist/Term\-Table/>.
239 .SH MAINTAINERS
240 .IX Header "MAINTAINERS"
241 .IP "Chad Granum <[email protected]>" 4
242 .IX Item "Chad Granum <[email protected]>"
243 .SH AUTHORS
244 .IX Header "AUTHORS"
245 .IP "Chad Granum <[email protected]>" 4
246 .IX Item "Chad Granum <[email protected]>"
247 .SH COPYRIGHT
248 .IX Header "COPYRIGHT"
249 Copyright 2016 Chad Granum <[email protected]>.
250 .PP
251 This program is free software; you can redistribute it and/or
252 modify it under the same terms as Perl itself.
253 .PP
254 See <https://dev.perl.org/licenses/>