php-markdown icon indicating copy to clipboard operation
php-markdown copied to clipboard

Add ID and class attribute support to tables

Open kburton opened this issue 11 years ago • 5 comments

Added support for {#id .class} attributes to tables when attributes are appended to the header line.

kburton avatar Feb 28 '14 15:02 kburton

I've implemented basic table attribute support, primarily so I could add the .table class (and others such as .table-striped) for Bootstrap 3 themed tables. This is used as follows:

Testing | Basic | Table {.table-class}
--------|-------|------
a       | b     | c

I could fairly easily implement a more powerful solution to allow the following if it would be useful:

Testing | Basic | Table {.th-row-class}
--------|-------|------ {.table-class}
a       | b     | c     {.td-row-class}
d       | e     | f     {.td-row-class-2}

or with the location of .table-class and .th-row-class switched.

kburton avatar Feb 28 '14 15:02 kburton

+1 like. ID/class for the whole table would be nice, to format layout via CSS.

markseuffert avatar Mar 04 '14 11:03 markseuffert

I'd rather have the attribute braces go before or after the table, but I can't decide between the two. It seems to me that putting the attribute list just after a row would take too much horizontal space: tables often take much horizontal space and with line wrapping taking more than what you have is inconvenient.

I've also been looking forward adding an optional caption to the table. Right now, I'm leaning towards something that looks like this right now:

[ Table 1: Insightful Data ] {.caption-class}
Testing | Basic | Table
--------|-------|------
a       | b     | c
{.table-class}

michelf avatar Mar 06 '14 19:03 michelf

I can see what you're saying, but I think that having attributes on separate lines before and after the table obscures the structure. I suppose that's going to be an inevitable consequence of trying to add attribute support to more HTML elements.

kburton avatar Mar 12 '14 14:03 kburton

Same need for me of adding a .table class at the table level for bootstrap.

I was inclined to add the class/id attributes after a tailing '|' of the header row, so as not to confuse it with internal annotation for the table cell, like

Testing | Basic | Table |{.table-class}
--------|-------|------
a       | b     | c

But the optional caption way would be fine as well. :)

jlj avatar Mar 15 '14 11:03 jlj