MichaelHatherly / CommonMark.jl

A CommonMark-compliant Markdown parser for Julia.
Other
84 stars 11 forks source link

[question] Strict alignment of pipes in tables #6

Closed tlienart closed 4 years ago

tlienart commented 4 years ago

In the docs you specify that the pipe symbols must be strictly aligned; is this a common mark requirement? would there be any ambiguity if that were relaxed // would it be possible to add a custom rule where this is relaxed?

We use it over in PkgPage and I've had feedback from people that the tables didn't look good which usually was because their | were not aligned (I think this is not required in GFM for instance)

Thanks!

Edit: maybe to substantiate why this rule seems unnecessarily constraining, consider this case:

| Column One | Column Two | Column Three |
|:---------- | ---------- |:------------:|
| Row `1`    | Column `2` |              |
| *Row* 2    | **Row** 2  | A very long cell with really a lot of text which might span multiple lines if your editor is constrained to 80 columns etc etc, it would be really dumb to have to require the top pipe to match this length, it would make the whole table less readable |

That stuff would work fine in GitHub:

Column One Column Two Column Three
Row 1 Column 2
Row 2 Row 2 A very long cell with really a lot of text which might span multiple lines if your editor is constrained to 80 columns etc etc, it would be really dumb to have to require the top pipe to match this length, it would make the whole table less readable and you would have to adjust all pipes whenever you're adding an entry that is longer than previous ones
MichaelHatherly commented 4 years ago

Not a commonmark requirement since the official spec doesn't make a ruling on tables yet. GFM, which is commonmark with extensions, allows for unaligned columns, but (last I checked), requires \| for literal pipes, regardless of where in a cell they are. It's possible to fix the parser to handle unaligned and not having the requirement of escaping pipes, but is just a bit tricky to get 100% right, hence I just went with the simple option for now. I'm fine with changing it though, but there's lots of low hanging fruit that's taking priority at the moment.