Allow table marker row to have more columns than header #253
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To match with Reddit's more lax table header/marker syntax (the header being the first row, and the marker row being the row after it that dictates the alignments), this change allows more marker/alignment columns than header columns.
For whatever reason this behavior/syntax is very common on Reddit, I assume because some folks will just edit the header row to remove a column, and then simply not update the alignment/marker row.
For instance this syntax renders a table on Reddit with 3 columns, but does not render with cmark-gfm as it has one too many marker/alignment columns:
markdown
But does render on Reddit as if the last marker/alignment column wasn't present, thus looking like this:
This PR changes the rules of the table extension to allow more marker/alignment columns than header columns.
It's a seemingly harmless change and all tests still pass. Note that the opposite (more header columns than marker/alignment columns) would fail the tests understandably as some header columns would not have an explicit alignment set.
I totally understand if this isn't behavior you're interested in/care about, I just integrated it into my app and appreciate this library and thus wanted to do the good thing and offer up my work in case you were interested!
(Shoutout to @QuietMisdreavus for helping me, any nice parts of this PR are thanks to her, and any mistakes are totally my fault.)