table icon indicating copy to clipboard operation
table copied to clipboard

New Table Template - Markdown

Open GantMan opened this issue 8 years ago • 2 comments

Great existing table templates, but one key item that's missing is the Markdown table.

| 0A | 0B | 0C |
|----|----|----|
| 1A | 1B | 1C |
| 2A | 2B | 2C |
| 2A | 2B | 2C |
| 2A | 2B | 2C |
| 2A | 2B | 2C |
| 2A | 2B | 2C |

Results in cool stuff on github, like so:

0A 0B 0C
1A 1B 1C
2A 2B 2C
2A 2B 2C
2A 2B 2C
2A 2B 2C
2A 2B 2C

Would be nice if we could give users a copy/paste friendly table for github!

https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#tables

GantMan avatar Nov 12 '17 00:11 GantMan

This works as long as the width of each column is >=3 characters.

table(data, {
  border: { 
    topBody: '',
    topJoin: '',
    topLeft: '',
    topRight: '',
    bottomBody: '',
    bottomJoin: '',
    bottomLeft: '',
    bottomRight: '',
    bodyLeft: '|',
    bodyRight: '|',
    bodyJoin: '|',
    joinBody: '-',
    joinLeft: '|',
    joinRight: '|',
    joinJoin: '|' 
  },
  drawHorizontalLine: (index) => index === 1
})

GantMan avatar Nov 12 '17 00:11 GantMan

Shame I can't combine the drawHorizontalLine, I could do the PR to add the template.

Maybe it should return a full config that can be extended? Thoughts? Not sure how to take it from here.

GantMan avatar Nov 12 '17 00:11 GantMan