What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 129 Stack Exchange communities.

This is similar to: Is there any markdown to create tables? and Please add support for tables in answers and questions, but is slightly different. The other questions are asking more of a why question, not a please do this question. I am asking for a specific implementation of Markdown tables. I found an article on making tables in Markdown using PHP Markdown or MultiMarkdown. The code to make a table looks like this:

| Left align | Right align | Center align |
|:-----------|------------:|:------------:|
| This       |        This |     This     |
| column     |      column |    column    |
| will       |        will |     will     |
| be         |          be |      be      |
| left       |       right |    center    |
| aligned    |     aligned |   aligned    |

And the result is:


This is much different than this answer, which says that Jeff doesn't want the <tr><td> tags allowed on the SE sites. This request has a specific feature request, as opposed to the other questions which don't really have a decisive yes/no answer.

Here are some specific posts that need this type of support:
Where can I find the unicode symbols for Mac functional keys? (Command, Shift, etc.)
Is there a way to directly link requirements to code units?

share|improve this question
4  
I find the need for left and right borders cumbersome, but otherwise this has potential –  Joel Coehoorn Jul 6 '12 at 19:27
1  
That code is really not the most user-friendly thing I've seen. Aren't there better ways? And the second question you linked to is actually a [friend-request] where the Moderator-only tag [status-bydesign] is kind of a decisive "no" answer. By the way, I'd like the table support. –  Alenanno Jul 6 '12 at 19:29
    
I like the idea, but I'm out of votes for today. @JoelCoehoorn If you mean you want no vertical bars to the left and the right of each line, I'd disagree. Then the system would interpret every line like one | two as a table, especially when you'd least expect it! –  Mr Lister Jul 6 '12 at 20:08
    
@Alenanno Yes I know and realize that the status-bydesign tag was on the question. However, I'd like to see a real answer. I also think my solution is one of, if not the best way to implement tables. In regards to other ways, I haven't seen anything else. –  daviesgeek Jul 6 '12 at 20:15
1  
This question is still a duplicate of "Please add support for tables in answers and questions", which specifically asks for the feature. And it has a decisive answer: NO. –  Nicol Bolas Jul 6 '12 at 21:13
    
@NicolBolas I would argue that it isn't a duplicate. My question has a Markdown specific request, not a Google Charts API request. Therefore, the question is the same, but the implementation that I'm asking for is much different. –  daviesgeek Jul 6 '12 at 22:09
1  
@daviesgeek: He didn't ask for Google Charts. He just posted that as a workaround. –  Nicol Bolas Jul 6 '12 at 22:13
11  
Funny, I saw this shortly after rescuing this old link only answer and was thinking 'Ya know, I hate the idea of Markdown tables until I need to make one, then I like the idea for a few days.' The developers have historically rejected anything not in the markdown standard and I support that, but perhaps we're big enough to influence the standard provided a suitable implementation can be hashed out? –  Tim Post Jul 7 '12 at 6:24
    
@TimPost That would be nice! :-) –  daviesgeek Jul 7 '12 at 6:31
    
FWIW, I prefer GitHub's implementation, as simple as pipe-delimited list but supports the full format if you need it. github.com/adam-p/markdown-here/wiki/… –  subkamran Feb 14 '13 at 20:00

2 Answers 2

I don't think we need to request support for tables via Markdown specifically, but I agree that tables would be helpful. On several SE sites, posts with tables could be improved if table support is added (or spreadsheets!). On gaming.SE, things like Minecraft crafting layouts would be possible without embedding images. I also started building a specific list of questions over on Scifi.SE that I think would be helped, as many concrete examples always help bolster a .

share|improve this answer
4  
I've seen many answers with tables, but they are always screenshots of a table, and that causes a lot of inconsistency... –  Cole Johnson Feb 10 '13 at 20:59

Over on DBA.SE, this would matter more than on most sites, but we have had our feature-request declined (too).

However, if I recall correctly, Anna Lear said there was some hope of a user-script being incorporated into the site if we can write one ourselves and get a good number of folk using it before raising the request again.

I don't know how to do this, but perhaps someone else would like to take the 'proof of principle' bit of jQuery I wrote and turn it into a proper script?

Jake Feasel has already kindly changed SQLFiddle to generate 'normal' markdown for tables like this:

a table:

|Item    |Value|
|--------|----:|
|Computer|$1600|
|Phone   |  $12|
|Pipe    |   $1|

Here's the code I came up with (tested on Firefox only and missing the justification feature):

$('div.post-text>pre').each(function(){ $(this).children().html($(this).children().html().replace(/(^\|.*\|$\n)+/gm,function(match){ var index = 0; return '<table style="margin: 0.5em; table-layout: fixed; font-size: smaller; background-color: white; box-shadow: 2px 2px 6px #777;">'+match.replace(/^(.*)$/gm,function(match){ var cell='th'; index++; if(index===2){ return ''; } if(index>2){ cell='td'; } return '<tr>'+match.replace(/^\|/,'<'+cell+'>').replace(/\|$/,'</'+cell+'>').replace(/\|/,'</'+cell+'><'+cell+'>')+'<tr>'; })+'</table>'; })); }).find('td,th').css('border','1px solid black').css('padding','2px').each(function(){ $(this).text($(this).text().replace(/^\s+|\s+$/g, '')); }).filter('th').css('background-color', '#eee')

Here's a screenshot of the output for those who can't run the script:

example

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .