mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
[PR #905] Fix pipe table parsing with a leading paragraph #1301
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/xoofx/markdig/pull/905
State: closed
Merged: Yes
Closes #818
Addresses issues referenced in https://github.com/xoofx/markdig/pull/885#issuecomment-3419948799, https://github.com/xoofx/markdig/pull/885#issuecomment-3419969194
This PR effectively reverts #885 as that change was swallowing whatever information was there in the paragraph before the table.
E.g. for
"Some text" would be lost.
Instead I relaxed the table validation to no longer enforce starting on the first line (
localLineIndex > 0anddeltaLine > 0checks), and also save the current block in the AST before we replace it with a table.Given this is happening while we're parsing inlines, I don't think we can easily insert an extra block at the current layer, so I instead added the leading paragrah as the first child of the table, and the first element is special-cased in the renderer.
That is, instead of
we're instead producing
Since
TableRowis a public type, this does risk breaking code that was walking the AST and assuming that all children of aTableareTableRows - this seems plausible given our own renderer did that.I'm open to alternative suggestions.