views:

68

answers:

1

I'm writing Multimarkdown tables following the guidelines under the Table section in the syntax guide, and I wish to convert them to HTML using Text::MultiMarkdown .

It works great, The only problem is I can't figure out how to control the formatting of the tables (show borders, align headers, font size etc).

+4  A: 

It's HTML so you will need to do the extra formatting in CSS (wikipedia entry).

To make MultiMarkdown use a CSS file you will need to add the necessary metadata to the document. From the Text::MultiMarkDown docs:

MultiMarkdown supports the concept of 'metadata', which allows you to specify a number of formatting options within the document itself. Metadata should be placed in the top few lines of a file, on value per line as colon separated key/value pairs. The metadata should be separated from the document with a blank line.

For eg:

use Text::MultiMarkdown 'markdown';

my $text = <<EOL;
css: table.css

|             |          Grouping           ||
First Header  | Second Header | Third Header |
 ------------ | :-----------: | -----------: |
Content       |          *Long Cell*        ||
Content       |   **Cell**    |         Cell |

New section   |     More      |         Data |
And more      |            And more          |
[Prototype table]
EOL

my $html = markdown( $text, {document_format => 'Complete'} );

NB. see the line css: table.css.

So $html in above will now contain the necessary stylesheet link to table.css. You just need to define the CSS in table.css to meet your formatting requirements. For eg:

caption { font-size: 200%;}
table   { border: 1px solid black; }
td,th   { border: 1px solid black; }
th      { width: 120px; }

/I3az/

draegtun