我如何格式化Multimarkdown表格? [英] How can I format Multimarkdown tables?
问题描述
我正在按照语法指南中表格部分的准则撰写Multimarkdown表格,我希望使用 Text :: MultiMarkdown 将它们转换为HTML。
效果很好,唯一的问题是我无法弄清楚如何控制表格的格式(显示边框,对齐页眉,字体大小等)。
要使 MultiMarkdown 使用CSS文件将需要为文档添加必要的元数据。从 Text :: MultiMarkDown
docs:
MultiMarkdown支持'metadata'的概念,它允许您在文档本身内指定一些格式选项。元数据应放置在文件的前几行,每行的值作为冒号分隔的键/值对。元数据应该与空行分开。
例如:
使用Text :: MultiMarkdown'markdown';
my $ text =<< EOL;
css:table.css
| |分组||
第一个标题|第二个标头|第三个标头|
------------ | :-----------:| -----------:|
内容| *长单元* ||
内容| ** Cell ** | Cell |
新节|更多|数据|
和更多|还有更多|
[原型表]
EOL
my $ html = markdown($ text,{document_format =>'Complete'});
注意。看到 css:table.css
这一行。
因此上面的 $ html
现在将包含必要的样式表链接到 table.css
。您只需在 table.css
中定义CSS即可满足您的格式要求。例如:
字幕{font-size:200%;}
table {border:1px solid black; }
td,th {border:1px纯黑色; }
th {width:120px; }
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).
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; }
这篇关于我如何格式化Multimarkdown表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!