Closed shawalli closed 3 years ago
I've identified the fix and am willing to contribute it, but I wanted to make sure it would be accepted before spending any more time on it.
@shawalli Thank you for your feedback.
Pull requests would always be welcome.
According to GitHub, there should be a space between each pipe and the alignment string
I just wonder which part describes that spec?
Here's the part from the spec that describes table alignment.
The delimiter row consists of cells whose only content are hyphens (-), and optionally, a leading or trailing colon (:), or both, to indicate left, right, or center alignment respectively.
Here is the example Markdown table incuded right below this text in the spec
| foo | bar |
| --- | --- |
| baz | bim |
So, I think this is where it could have been more explicit. In all of the table examples, there is always a space between the separator character (i.;e. |
) and any content, including alignment characters. So in the above documentation, while is doesn't say that there should be a space specifically in the alignment cells, it implies it by always having a space before and/or after the separator.
After investigating this further as part of this reply, perhaps the "right" fix is to have the alignment row respect the margin
argument, so that a margin of 1 would produce this behavior. This way, all row/cell types (header, alignment,content) would obey margin
. Right now, it uses margin
to extend the alignment characters, but the calculation could be modified to left- and right-pad spaces by margin
characters on each side.
What are your thoughts?
In my opinion, examples are just examples, not a spec unless explicitly stated.
GFM accepts tables even if without spaces around hyphens (---
).
However, it might be good idea to match the output table format with popular formatter tools like prettier.
the alignment row respect the margin argument, so that a margin of 1 would produce this behavior. This way, all row/cell types (header, alignment,content) would obey margin.
Sounds good.
Currently, Markdown tables look like this:
According to GitHub, there should be a space between each pipe and the alignment string, like so:
This discrepancy causes linters (e.g.
preettier
) which do conform to GFM to constantly change the header row for tables that have been generated with this library.