Several sites have MathJax enabled, so there is obviously some room for site-specific markdown.

Therefore please can we have markdown tables here on dba.se? There is an open feature-request for this on mSO, but whereas it is hardly a key feature for a programming Q&A site, a significant percentage of our questions and answers contain tabular sample data, and real tables will make them neater and easier to read.

All we can do now is use ascii art but this has a number of drawbacks.

If the feature request goes through I'm pretty sure Jake Feasel will be happy to tweak SQL Fiddle to make it produce compatible markdown.

-- edit:

I've discovered that MathJax isn't implemented as a markdown extension after all, it is a script that runs on the page. Apparently the 'Go' board game site had it's own code as well for displaying board positions, but I'm not sure whether that was markdown or a script.

Anyway, this feature-request is specifically for a markdown extension, the script in my answer is just to prove the principle. We'd settle for a Javascript solution if that's the only thing on offer though!


We're rolling out markdown support for tables here and on Meta Stack Exchange. Full details are in this announcement on MSE. Please play around with the feature and let us know if we missed anything over on Meta Stack Exchange.

Here's the roll-out plan (and a table for you to look at!)

What? When? Where?
Table support 2020-11-23 Meta Stack Exchange & DBA Meta
More table support week of 2020-11-30 DBA Stack Exchange
Even more table support week of 2020-12-07 Network-wide launch (if no major issues found)

Have fun!

a table:

|Item    |Value|
|Phone   |  $12|
|Pipe    |   $1|

a wide table:

|Item    |Value|
|Phone   |  $12|
|Pipe    |   $1|

a table and a wide table:

|Item    |Value|
|Phone   |  $12|
|Pipe    |   $1|

|Item    |Value|
|Phone   |  $12|
|Pipe    |   $1|

I've added this table as part of a plan to develop a userscript demo-ing the result.

For now, try this on the browser console (tested on Firefox only):

$('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')

This is just to prove the principle and I don't expect it to be robust. It's also missing features like justification at the moment.

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

enter image description here

  • 5
    Neat! Works in Chrome too. – Mat May 15 '13 at 5:52
  • Thanks @Mat, that is good to know – Jack Douglas May 15 '13 at 6:28
  • @Mat would you mind checking the new version in Chrome too? – Jack Douglas May 15 '13 at 10:30
  • Works fine on Chrome 26.0.1410.64, all four tables look good. – Mat May 15 '13 at 11:07
  • Pure magic! tested on Chromium 25.0.1364.160 Ubuntu 12.10 – dezso May 15 '13 at 11:41
  • @dezso great, thanks. I'm hoping SE will build this into the Markdown for dba.se rather than adding a script like this to our pages, so this is just to prove it's possible. We'll see! – Jack Douglas May 15 '13 at 12:09
  • 2
    This is an ability that is sorely needed across every site to which I post. And that includes Stack Overflow, Space, Sci-Fi and Fantasy, Movies.. – Andrew Thompson Mar 22 '14 at 4:14
  • @Andrew yes it's useful everywhere for some Q&A, here it's useful for the vast majority though: if we don't get it I'm guessing nobody will :( – Jack Douglas Mar 22 '14 at 7:28

An alternative, not so nice but simpler, would be to have css line-height: 1 set for code blocks (.post-text pre { line-height: 1; }) on dba.se.

Unicode tables like this would then not have broken lines:

values ('Donald Duck')
     , ('Micky Mouse');

│   column1   │
│ Donald Duck │
│ Micky Mouse │

so they would look like this:

enter image description here

The lines of code are squashed together now, but I don't think it looks worse, maybe even an improvement.

  • I ran this by Jin and he wasn't on board. Sorry. – Adam Lear ModStaff Jun 9 '14 at 20:40
  • 5
    @JackDouglas ... UI coding is hard. we'd rather do things like split meta (that breeding ground of whinging, hatred, and other unsavory behaviors) than enhance usability. – swasheck Jun 9 '14 at 20:44

At this point we have no plans to extend Markdown syntax to support tables. The extension itself isn't the hard part. The display of tables in posts would be fairly hard to get right.

There are a few extensions already (like what PHP Markdown does), but the syntax isn't very intuitive, and it's very easy to start breaking page layout with tables, nested tables, and so on.

I think the userscript Jack started working on is a step in the right direction, but it doesn't seem to make tables significantly prettier or easier to read than their raw ASCII versions.

My advice for now is to continue developing your script if you think it's necessary. Get it to the point where many people are using it, and we can see about integrating it into the site itself.

Update (March 2016): we are using CommonMark for topics and examples created in Documentation. The CommonMark parser we have does include table support and we have talked about eventually switching Q&A over to it as well some time after Documentation leaves private beta. However, unfortunately at the moment I don't have anything that even resembles an ETA.

Update (November 2020): We are now testing table support!

  • 8
    Thanks for getting back to us Adam. Maybe I'm missing something but I don't understand this "The display of tables in posts would be fairly hard to get right". That's the point of my script, isn't it, to demonstrate an acceptable way of displaying tables. In this case we are suggesting they are only allowed inside code sections and of course the markdown extension would not allow nesting (or do you mean the nesting of this table within the tables used for layout on the main page?—in which case, haven't we demonstrated that it doesn't break the page layout, at least here on meta?) – Jack Douglas May 17 '13 at 14:20
  • 1
    @JackDouglas I was talking about implementing table support in Markdown in general. We don't want to complicate the syntax or diverge too far from the public Markdown spec. If we're going to do that at all, we can't just stop at a halfbaked table implementation that only suits one site. Your script takes us closer to something usable for DBA.SE specifically, but (and maybe I just don't fully appreciate the issues with the ASCII tables) I'm honestly not seeing much difference from just showing the ASCII table in the first place. – Adam Lear ModStaff May 18 '13 at 4:11
  • If SQL Fiddle can theoretically produce acceptable Markdown (if this were implemented), can't it produce an ASCII table you can just copy and paste into a post? – Adam Lear ModStaff May 18 '13 at 4:11
  • 1
    Hi Adam, yes there is quite a bit we can do with Ascii Art, including output from SQLFiddle. It's a bit ugly, but imo worse than that, it is wide. Each vertical takes one char of our limited space, and using hacks like <sub> mess with the lines (having <small> etc would actually be a great improvement). Anyway, I've added prettier tables to my proof of principle above: I'd made no effort to make them look nice before as I was trying to show that they wouldn't mess with the layout. – Jack Douglas May 18 '13 at 7:46
  • Of course there is no markdown spec for tables, so any solution inside markdow could be regarded as 'half-baked'. In fact I think enabling tables generally would be a disaster for the layout as Tim mentioned, so the only option is a strictly restricted syntax. I imagined it would only be for dba.se, but reading between the lines, am I right to be hearing that markdown=network and userscript=site-specific? If that is set in stone, I may give up pushing for a markdown solution as a network-wide change is probably a lost cause, I've only ever been asking for a dba.se site-specific change. – Jack Douglas May 18 '13 at 7:50
  • Not prettier? Do we watch the same movie? The table above is much better than any ascii-art. – dezso May 18 '13 at 15:45
  • Thanks Adam, in the meantime I've accepted your answer, because, well, whatever you say is the answer :) – Jack Douglas May 18 '13 at 19:24
  • 6
    Thank you! Even without an ETA this is really encouraging :) – Jack Douglas Mar 17 '16 at 18:14
  • 2
    In addition to @JackDouglas 's comment above I would like to say I'm impressed and appreciative that you remembered this post years later, and cared enough to give us this status update. – Erik Mar 20 '16 at 12:01
  • 1
    @Erik Alas, I can't take credit for remembering. :) Paul White pinged me in chat and asked if there were any updates. – Adam Lear ModStaff Mar 20 '16 at 17:37
  • @AdamLear "...eventually switching Q&A over to it as well some time after Documentation leaves private beta." Any chance there's an update on this, since Documentation launched publicly last year? <hopeful grin> – AMtwo Staff Apr 12 '17 at 18:28
  • @AMtwo Not at the moment, sorry. Switching out the markdown parser is a pretty big undertaking and it's pretty down on the list. – Adam Lear ModStaff Apr 12 '17 at 18:39
  • @AdamLear Is this still a possibility since the closing of Documentation? – LowlyDBA - John M Oct 10 '17 at 19:40
  • 1
    @LowlyDBA It is, but at roughly the same priority as before - pretty down on the list, definitely not happening this year. – Adam Lear ModStaff Oct 10 '17 at 20:06
  • Thanks for the non-ETA. Sounds kind of promising... – John K. N. Jan 15 '18 at 13:27

You must log in to answer this question.

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