Skip to content

Instantly share code, notes, and snippets.

@gshutler
Created August 11, 2012 21:02
Show Gist options
  • Save gshutler/3327300 to your computer and use it in GitHub Desktop.
Save gshutler/3327300 to your computer and use it in GitHub Desktop.
Idea for creating a table in markdown

Possible Markdown for tables

I noticed that there isn't a format for creating tables in Markdown.

My idea is to just use the | (pipe) character to delimit columns in a table with the first line of "cells" always assumed to be a row of headings:

 | Number | Rider        | Time  |
 | 1      | Bullet Bob   | 56:07 |
 | 2      | Clumsy Colin | DNF   |
 | 3      | Swift Susan  | 55:13 |

There would be a leader of a single space followed by a pipe |. The rest of the line would be split on pipes with the last pipe being optional. That means this would be equivalent:

 | Number | Rider        | Time
 | 1      | Bullet Bob   | 56:07
 | 2      | Clumsy Colin | DNF 
 | 3      | Swift Susan  | 55:13

The table would be closed off by a blank line. This should cover the majority of simple cases and feels right when being viewed as plain text and in the standard Markdown vocabulary. The alignment would be optional but I couldn't bring myself to create a version that wasn't lined up!

Fuller example

Markdown

# Race results

Here are the results from this week's race:

 | Number | Rider        | Time
 | 1      | Bullet Bob   | 56:07
 | 2      | Clumsy Colin | DNF 
 | 3      | Swift Susan  | 55:13

Congratulations to all who took part and I look forward to seeing you all at the next one!

Output

Race results

Here are the results from this week's race:

NumberRiderTime
1Bullet Bob56:07
2Clumsy ColinDNF
3Swift Susan55:13

Congratulations to all who took part and I look forward to seeing you all at the next one!

@adambird
Copy link

Looks splendid

@gshutler
Copy link
Author

I didn't get any notification about your comment, perhaps that got lost in the Github overhaul.

@joseguera
Copy link

Great examples. Very helpful 🏆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment