commonmark / commonmark-spec

CommonMark spec, with reference implementations in C and JavaScript
http://commonmark.org
Other
4.89k stars 317 forks source link

Proposal: A Simple Structure for Pipe Tables #743

Closed anasram closed 1 year ago

anasram commented 1 year ago

The Current Situation

Typically there're two kinds of pipe tables in Markdown:

Readable Pipe Tables

Note: The following example tables are drawn from Pandoc manual.

| Right | Left | Default | Center |
|------:|:-----|---------|:------:|
|   12  |  12  |    12   |    12  |
|  123  |  123 |   123   |   123  |
|    1  |    1 |     1   |     1  |

: Demonstration of pipe table syntax.
| One | Two   |
|-----+-------|
| my  | table |
| is  | nice  |

: Nice pipe table 1
| One | Two   |
|-----|-------|
| my  | table |
| is  | nice  |

: Nice pipe table 2

Editable Pipe Tables

One | Two
---|---
my | table
is | ugly

: Ugly pipe table 1
fruit | price
------|-----:
apple | 2.05
pear | 1.37
orange | 3.09

: Ugly pipe table 2

The Problem

As a Solution

Making editable tables (ugly pipe tables) readable (nice), is a mission that should be entrusted to text editors that support (understand) Markdown.

This means two things for text editors:

  1. Preventing word warp for markdown tables, even if this option is active in the text editor.
  2. Using Flexible Tabs and Spaces for markdown tables.

Accordingly, the previous table should look like this automatically:

fruit  | price
-------|-----:
apple  | 2.05
pear   | 1.37
orange | 3.09

: Ugly pipe table looks nice

But we still have a problem here: Text editor should add additional hyphens - under the header cells for this purpose too, i.e. making the table readable.

As a solution, I propose using **...** in a cell to refer to a th element, instead of a strong element. In this case the line of hyphens won't be required. Like this:

**fruit** | **price**:
apple     | 2.05
pear      | 1.37
orange    | 3.09

: Ugly pipe table looks nice

As you can see, the colon : can be added to the heading cells itself for alignment.

Another benefit of this way to represent header cells is to set any cell as header cell. Like this:

**fruit**  | **price**:
**apple**  | 2.05
**pear**   | 1.37
**orange** | 3.09

: Ugly pipe table looks nice
wooorm commented 1 year ago

Tables are not part of this project. I think you’re talking about GFM?

anasram commented 1 year ago

Mmm, well, then let's consider this proposal as a begging to support tables in this project! :)

Otherwise, maybe I should submit this to Pandoc directly, regardless of the markdown flavor?

wooorm commented 1 year ago

This repo is the spec, so issues are typically more about concrete proposals. More discussion like place is https://talk.commonmark.org. Which I know has a ton of discussions about tables.

If you use pandoc, and only really care about that, that’s probably a better place to ask.

If you only care about GH, which is the most standard-like thing that defines these, you’re probably better off asking them. But: they don’t really have people on the project. So it’s highly unlikely anything will ever happen with this.