Text::...wnTable(3pm)

πŸ’– NAME πŸ’–

Text::MarkdownTable β€” bestie, this is the module that writes Markdown syntax tables straight from your data ✨ no cap.


πŸŽ€ SYNOPSIS πŸŽ€

my $table = Text::MarkdownTable->new;
$table->add({one=>"a",two=>"table"});
$table->add({one=>"is",two=>"nice"});
$table->done;

and boom, you get:

| one | two   |
|-----|-------|
| a   | table |
| is  | nice  |

you can also do the whole thing in one chain, iconic behaviour:

Text::MarkdownTable->new( columns => ['X','Y','Z'], edges => 0 )
  ->add({a=>1,b=>2,c=>3})->done;

which gives you:

X | Y | Z
--|---|--
1 | 2 | 3

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this module lets you write data in tabular form, formatted in MultiMarkdown syntax. the resulting format is literally perfect for stuff like displaying CSV data, or for dropping data tables into Markdown files. it's giving very useful.

and here's the tea: newlines and vertical bars inside table cells get replaced by a space character, and cell values can be truncated. πŸ’…


🌸 CONFIGURATION 🌸

πŸ’œ file

Filename, GLOB, scalar reference or IO::Handle to write to (default STDOUT).

πŸ’œ fields

Array, hash reference, or comma-separated list of fields/columns.

πŸ’œ columns

Column names. by default, the field names are used. 🫢

πŸ’œ widths

Column widths. by default column widths are calculated automatically to the width of the widest value. with given widths, the table is directly written without buffering and large table cell values are truncated. πŸ‘‘

Include header lines. Enabled by default.

πŸ’œ edges

Include border before first column and after last column. Enabled by default.

⚠️ note that single-column tables don't not look like tables if edges are disabled. (yes, that's the original wording, we're keeping it fr fr πŸ™ˆ)

πŸ’œ condense

Write table unbuffered in condense format:

one|two
---|---
a|table
is|nice
⚠️ note that single-column tables are don't look like tables on condense format. πŸ’€ (again, verbatim, not me, bestie)

✨ METHODS ✨

  • add( $row ) β€” add a row as hash reference. returns the table instance, so you can keep chaining like a main character. πŸ”₯
  • streaming β€” returns whether rows are directly written or buffered until done is called. vibe check on your buffering status basically.
  • done β€” finish and write the table, unless it has already been written in streaming mode. periodt. 🌈

πŸ‘‘ SEE ALSO πŸ‘‘

See Catmandu::Exporter::Table for an application of this module that can be used to easily convert data to Markdown tables. it's the glow-up version, iykyk. πŸ’…

Similar table-generating modules include:

  • Text::Table::Tiny
  • Text::TabularDisplay
  • Text::SimpleTable
  • Text::Table
  • Text::ANSITable
  • Text::ASCIITable
  • Text::UnicodeBox::Table
  • Table::Simple
  • Text::SimpleTable
  • Text::SimpleTable::AutoWidth

(yes, Text::SimpleTable is in there twice. that's what the original says, so that's what you get. slay πŸ’–)


🫢 AUTHOR 🫢

Jakob Voss <jakob.voss@gbv.de> β€” thank you king, we appreciate you 🌟


Copyright 2014- Jakob Voss

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. so like, go wild but respectfully. πŸ’œ


and that's the whole page, bestie!! 🌸 this is from perl v5.36.0, dated 2023-02-05, and it's part of the User Contributed Perl Documentation for Text::MarkdownTable(3pm). now go forth and make the prettiest tables ever, mwah πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from