.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
.ie n \{\
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Term::Table 3perl"
.TH Term::Table 3perl 2024-09-01 "perl v5.40.0" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH NAME
Term::Table \- Format a header and rows into a table
.SH DESCRIPTION
.IX Header "DESCRIPTION"
This is used by some failing tests to provide diagnostics about what has gone
wrong. This module is able to format rows of data into tables.
.SH SYNOPSIS
.IX Header "SYNOPSIS"
.Vb 1
\& use Term::Table;
\&
\& my $table = Term::Table\->new(
\& max_width => 80, # Defaults to terminal size
\& pad => 4, # Extra padding between table and max\-width (defaults to 4)
\& allow_overflow => 0, # Default is 0, when off an exception will be thrown if the table is too big
\& collapse => 1, # Do not show empty columns
\&
\& header => [\*(Aqname\*(Aq, \*(Aqage\*(Aq, \*(Aqhair color\*(Aq],
\& rows => [
\& [\*(AqFred Flintstone\*(Aq, 2000000, \*(Aqblack\*(Aq],
\& [\*(AqWilma Flintstone\*(Aq, 1999995, \*(Aqred\*(Aq],
\& ...
\& ],
\& );
\&
\& say $_ for $table\->render;
.Ve
.PP
This prints a table like this:
.PP
.Vb 7
\& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+
\& | name | age | hair color |
\& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+
\& | Fred Flintstone | 2000000 | black |
\& | Wilma Flintstone | 1999995 | red |
\& | ... | ... | ... |
\& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+
.Ve
.SH INTERFACE
.IX Header "INTERFACE"
.Vb 2
\& use Term::Table;
\& my $table = Term::Table\->new(...);
.Ve
.SS OPTIONS
.IX Subsection "OPTIONS"
.IP "header => [ ... ]" 4
.IX Item "header => [ ... ]"
If you want a header specify it here.
This takes an arrayref with each columns heading.
.IP "rows => [ [...], [...], ... ]" 4
.IX Item "rows => [ [...], [...], ... ]"
This should be an arrayref containing an arrayref per row.
.ie n .IP "collapse => $bool" 4
.el .IP "collapse => \f(CW$bool\fR" 4
.IX Item "collapse => $bool"
Use this if you want to hide empty columns, that is any column that has no data
in any row. Having a header for the column will not effect collapse.
.ie n .IP "max_width => $num" 4
.el .IP "max_width => \f(CW$num\fR" 4
.IX Item "max_width => $num"
Set the maximum width of the table, the table may not be this big, but it will
be no bigger. If none is specified it will attempt to find the width of your
terminal and use that, otherwise it falls back to the terminal width or \f(CW80\fR.
.ie n .IP "pad => $num" 4
.el .IP "pad => \f(CW$num\fR" 4
.IX Item "pad => $num"
Defaults to \f(CW4\fR, extra padding for row width calculations.
Default is for legacy support.
Set this to \f(CW0\fR to turn padding off.
.ie n .IP "allow_overflow => $bool" 4
.el .IP "allow_overflow => \f(CW$bool\fR" 4
.IX Item "allow_overflow => $bool"
Defaults to \f(CW0\fR. If this is off then an exception will be thrown if the table
cannot be made to fit inside the max-width. If this is set to \f(CW1\fR then the
table will be rendered anyway, larger than max-width, if it is not possible
to stay within the max-width. In other words this turns max-width from a
hard-limit to a soft recommendation.
.ie n .IP "sanitize => $bool" 4
.el .IP "sanitize => \f(CW$bool\fR" 4
.IX Item "sanitize => $bool"
This will sanitize all the data in the table such that newlines, control
characters, and all whitespace except for ASCII 20 \f(CW\*(Aq \*(Aq\fR are replaced with
escape sequences. This prevents newlines, tabs, and similar whitespace from
disrupting the table.
.Sp
\&\fBNote:\fR newlines are marked as \f(CW\*(C`\en\*(C'\fR, but a newline is also inserted into the
data so that it typically displays in a way that is useful to humans.
.Sp
Example:
.Sp
.Vb 1
\& my $field = "foo\enbar\enbaz\en";
\&
\& print join "\en" => table(
\& sanitize => 1,
\& rows => [
\& [$field, \*(Aqcol2\*(Aq ],
\& [\*(Aqrow2 col1\*(Aq, \*(Aqrow2 col2\*(Aq]
\& ]
\& );
.Ve
.Sp
Prints:
.Sp
.Vb 7
\& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
\& | foo\en | col2 |
\& | bar\en | |
\& | baz\en | |
\& | | |
\& | row2 col1 | row2 col2 |
\& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
.Ve
.Sp
So it marks the newlines by inserting the escape sequence, but it also shows
the data across as many lines as it would normally display.
.ie n .IP "mark_tail => $bool" 4
.el .IP "mark_tail => \f(CW$bool\fR" 4
.IX Item "mark_tail => $bool"
This will replace the last whitespace character of any trailing whitespace with
its escape sequence. This makes it easier to notice trailing whitespace when
comparing values.
.ie n .IP "show_header => $bool" 4
.el .IP "show_header => \f(CW$bool\fR" 4
.IX Item "show_header => $bool"
Set this to false to hide the header. This defaults to true if the header is
set, false if no header is provided.
.ie n .IP "auto_columns => $bool" 4
.el .IP "auto_columns => \f(CW$bool\fR" 4
.IX Item "auto_columns => $bool"
Set this to true to automatically add columns that are not named in the header.
This defaults to false if a header is provided, and defaults to true when there
is no header.
.ie n .IP "no_collapse => [ $col_num_a, $col_num_b, ... ]" 4
.el .IP "no_collapse => [ \f(CW$col_num_a\fR, \f(CW$col_num_b\fR, ... ]" 4
.IX Item "no_collapse => [ $col_num_a, $col_num_b, ... ]"
.PD 0
.ie n .IP "no_collapse => [ $col_name_a, $col_name_b, ... ]" 4
.el .IP "no_collapse => [ \f(CW$col_name_a\fR, \f(CW$col_name_b\fR, ... ]" 4
.IX Item "no_collapse => [ $col_name_a, $col_name_b, ... ]"
.ie n .IP "no_collapse => { $col_num_a => 1, $col_num_b => 1, ... }" 4
.el .IP "no_collapse => { \f(CW$col_num_a\fR => 1, \f(CW$col_num_b\fR => 1, ... }" 4
.IX Item "no_collapse => { $col_num_a => 1, $col_num_b => 1, ... }"
.ie n .IP "no_collapse => { $col_name_a => 1, $col_name_b => 1, ... }" 4
.el .IP "no_collapse => { \f(CW$col_name_a\fR => 1, \f(CW$col_name_b\fR => 1, ... }" 4
.IX Item "no_collapse => { $col_name_a => 1, $col_name_b => 1, ... }"
.PD
Specify (by number and/or name) columns that should not be removed when empty.
The 'name' form only works when a header is specified. There is currently no
protection to insure that names you specify are actually in the header, invalid
names are ignored, patches to fix this will be happily accepted.
.SH "NOTE ON UNICODE/WIDE CHARACTERS"
.IX Header "NOTE ON UNICODE/WIDE CHARACTERS"
Some unicode characters, such as \f(CW\*(C`婧\*(C'\fR (\f(CW\*(C`U+5A67\*(C'\fR) are wider than others. These
will render just fine if you \f(CW\*(C`use utf8;\*(C'\fR as necessary, and
Unicode::GCString is installed, however if the module is not installed there
will be anomalies in the table:
.PP
.Vb 7
\& +\-\-\-\-\-+\-\-\-\-\-+\-\-\-+
\& | a | b | c |
\& +\-\-\-\-\-+\-\-\-\-\-+\-\-\-+
\& | 婧 | x | y |
\& | x | y | z |
\& | x | 婧 | z |
\& +\-\-\-\-\-+\-\-\-\-\-+\-\-\-+
.Ve
.SH SOURCE
.IX Header "SOURCE"
The source code repository for \f(CW\*(C`Term\-Table\*(C'\fR can be found at
.
.SH MAINTAINERS
.IX Header "MAINTAINERS"
.IP "Chad Granum " 4
.IX Item "Chad Granum "
.SH AUTHORS
.IX Header "AUTHORS"
.PD 0
.IP "Chad Granum " 4
.IX Item "Chad Granum "
.PD
.SH COPYRIGHT
.IX Header "COPYRIGHT"
Copyright 2016 Chad Granum .
.PP
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
.PP
See