Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set table column width via Markdown

Tags:

markdown

I have a project using Slate, which allows using table markup in the following format.

Name | Value -------|------------------- `Value-One` | Long explanation `Value-Two` | Long explanation `etc` | Long explanation 

My problem is that the first column is rendered too narrow, and is wrapping the content (i.e. breaking the code values onto two lines) rather than displaying it on a single line. My preference is that the first column be wide enough to display the name/key fully, and then the second column can take up the rest of the available space.

My question is if it is possible (and therefore, how) to set the column width via markup, or at least add a class to the table via markup (so that I can style a particular table via CSS). Or is there a better approach to this? I'd prefer not to have to write out the table in full HTML (which would be a last resort option).

like image 983
pnairn Avatar asked Mar 21 '16 01:03

pnairn


People also ask

Can you do tables in Markdown?

Markdown makes it simple to format text online, such as bold text, and links. You can even make tables with Markdown.

How do you width a table in HTML?

To set the table width in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <table> tag, with the CSS property width.


1 Answers

I was looking the answer for a long time and finally figured out this solution. markdown columns width is determined by the longest cell in the column, so use html space entity &nbsp; as many times as needed to widen the column. it looks ugly in edit mode but finally do the trick:

Name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | Value -------|------------------- `Value-One` | Long explanation `Value-Two` | Long explanation `etc` | Long explanation 
like image 94
Paweł Avatar answered Oct 09 '22 14:10

Paweł