Fix, and document, some table/paragraph interrupt corner cases #672
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.
Fixes #540
interrupting paragraphs with tables
Pulldown-cmark gives "heavy" tables (with a leading
|
) higher priority than "light" tables for paragraph interruption. This is compatible with older versions of GitHub, but 2023-06-21 GitHub treats them the same.A quick run through https://babelmark.github.io shows, of the implementations that support pipe tables at all1:
A lot of Extended Markdown parsers don't allow tables to interrupt paragraphs at all, even if they support pipe tables in general.
Out of the ones that do, about half of them do what GitHub does and disallow it when the table is indented by four or more spaces.
ambiguity between "light" tables and h2
This PR also changes
scan_table_head
to refuse any table with zero pipes at all in its header line. This resolves an ambiguity with settext-style<h2>
, and matches every other Markdown implementation I could fine in Babelmark (see interrupting paragraphs with tables, "table j"), exceptmaruku
andmarkdown-it
, which behave very strangely.ambiguity with "light" tables and bulleted lists with
-
This PR adds a test case for the existing behavior on tables like this:
a | b - | - 1 | 2
It doesn't change the behavior, but it does document it.
hard line breaks are not allowed at the end of table header lines
Hard line breaks are not allowed at the end of table header lines. It's about a 50:50 split on babelmark, but this change makes pulldown-cmark consistent with GFM and Pandoc.
Footnotes
Implementations that "support pipe tables at all" were identified by
including "table a" without a preceding paragraph and seeing if it
produced an HTML table for that. ↩
On "table h" and "table i", DFM sees a table with no cells, followed
by a paragraph with
b
in it. ↩On "table j", maruku and markdown-it see a table with no cells, followed
by a paragraph with
b
in it. ↩ ↩2On "table i", markdown-it sees a table with no cells, followed
by a paragraph with
b
in it. ↩