Markdown::Parser::Table - Markdown Table Element
my $o = Markdown::Parser::Table->new; $o->caption( $o->create_table_caption( @_ ) ); $o->head( $o->create_table_head( @_ ) ); $o->add_body( $o->create_table_body( @_ ) ); print $o->as_string, "\n"; # returns html representation of the data print $o->as_markdown, "\n"; # returns markdown representation of the data
v0.2.0
This is a class object to represent an entire table. It is used by Markdown::Parser and inherits from Markdown::Parser::Element
For example:
Instantiate a new table object, which can take the following parameters:
This is a CSS::Object object
This is the internal value to identify the table object. It is set to table and should not be changed
table
A boolean value to set whether to return the table as a css grid rather than as an html table.
When set to true, "as_string" returns "as_css_grid" instead
Provided with a Markdown::Parser::TableBody object, and this adds it to the stack of Markdown::Parser::TableBody objects.
Provided with a Markdown::Parser::TableHeader object, and this adds it to the stack of Markdown::Parser::TableHeader objects.
Returns this table as a CSS grid as a regular string.
This is quite a nifty feature that enables you to transform effortlessly a table into a CSS grid.
Returns a string representation of the table formatted in markdown.
This method will call "caption" if one is set, "header" and "bodies" and get their respective markdown representation of their part.
It returns a plain string.
Returns a string representation of the table formatted in pod.
Returns an html representation of the table. It calls "caption" if one is set, "header" and "bodies" to get their respective html representation.
Sets or gets a Module::Generic::Array object containing Markdown::Parser::TableBody objects.
Alias for "bodies"
Sets or gets a Markdown::Parser::TableCaption object.
When an Markdown::Parser::TableCaption object is provided, this method automatically sets the object "parent" in Markdown::Parser::Element property to the current table object.
Returns the current value set.
Sets or gets a Markdown::Parser::TableHeader object.
When an Markdown::Parser::TableHeader object is provided, this method automatically sets the object "parent" in Markdown::Parser::Element property to the current table object.
Sets or gets a Module::Generic::Array object containing Markdown::Parser::TableHeader objects.
Provided with a Markdown::Parser::TableBody object, and this will remove it from the stack of Markdown::Parser::TableBody objects.
Returns the object removed if it was found, or undef otherwise.
Reset the hash reference containing general computed data on the table.
Returns a hash object from Module::Generic::Hash containing table computed data information.
Available information are:
This field key is an integer starting from zero like an array offset. The field value is the width of the cell
In the example above, cell 0 could be, for example, having a width of 10 characters, while cell 1 could be 12 characters and cell 3 too.
$stat->{cols}->{0}; # 10 characters wide
This field contains an integer representing the total number of columns for a row in the table
This field contains the number of rows in the header
This field contains the total number of rows in the table bodies. So its value is an integer.
This field contains an integer representing the table width. However, the width here is in number of characters, not in pixel, so you would need to convert it. The conversion ratio is 8 pixels per character.
Jacques Deguest <jack@deguest.jp>
Copyright (c) 2020 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.
To install Markdown::Parser, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Markdown::Parser
CPAN shell
perl -MCPAN -e shell install Markdown::Parser
For more information on module installation, please visit the detailed CPAN module installation guide.