mirror of
https://github.com/xoofx/markdig.git
synced 2026-07-09 02:26:32 +00:00
[PR #905] [MERGED] Fix pipe table parsing with a leading paragraph #1296
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?
📋 Pull Request Information
Original PR: https://github.com/xoofx/markdig/pull/905
Author: @MihaZupan
Created: 10/20/2025
Status: ✅ Merged
Merged: 10/20/2025
Merged by: @xoofx
Base:
master← Head:table-para📝 Commits (2)
6f84428Fix pipe table parsing with a leading paragraphcf79677Use the alternative approach📊 Changes
6 files changed (+145 additions, -14 deletions)
View changed files
📝
src/Markdig.Tests/Specs/GridTableSpecs.generated.cs(+29 -0)📝
src/Markdig.Tests/Specs/GridTableSpecs.md(+21 -0)📝
src/Markdig.Tests/Specs/PipeTableSpecs.generated.cs(+33 -0)📝
src/Markdig.Tests/Specs/PipeTableSpecs.md(+25 -0)📝
src/Markdig.Tests/TestPipeTable.cs(+1 -0)📝
src/Markdig/Extensions/Tables/PipeTableParser.cs(+36 -14)📄 Description
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.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.