[PR #455] [MERGED] Pipe Tables: Normalize using header column count #1042

Open
opened 2026-01-29 14:48:57 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/xoofx/markdig/pull/455
Author: @hamvocke
Created: 7/30/2020
Status: Merged
Merged: 7/30/2020
Merged by: @xoofx

Base: masterHead: master


📝 Commits (5)

  • 8fa4742 change test for pipe table normalization
  • 0eab0a3 set up example006 of pipe table spec according to new behavior
  • be53e77 remove extra cells, use header row to find maxColumn
  • 4390ff2 add option to PipeTableOptions, use for normalization
  • cb0b3a6 add 'gfm-pipetables' pipeline mode, introduce new gfm test spec

📊 Changes

9 files changed (+1541 additions, -7 deletions)

View changed files

src/Markdig.Tests/Specs/PipeTableGfmSpecs.generated.cs (+857 -0)
src/Markdig.Tests/Specs/PipeTableGfmSpecs.md (+617 -0)
📝 src/Markdig.Tests/Specs/PipeTableSpecs.generated.cs (+1 -1)
📝 src/Markdig.Tests/Specs/PipeTableSpecs.md (+1 -1)
📝 src/Markdig/Extensions/Tables/PipeTableOptions.cs (+13 -1)
📝 src/Markdig/Extensions/Tables/PipeTableParser.cs (+8 -1)
📝 src/Markdig/Extensions/Tables/Table.cs (+39 -2)
📝 src/Markdig/MarkdownExtensions.cs (+4 -1)
📝 src/SpecFileGen/Program.cs (+1 -0)

📄 Description

This is a potential fix for #454.

In this PR I'm introducing PipeTableOptions.UseHeaderForColumnCount, an option that allows switching the PipeTables extension's normalization behavior. It's defaulting to the current behavior (find the row with the most columns and make sure all other rows have the same amount of cells). When setting this option to true, the normalization will follow the example in GitHub's spec and remove/add cells in all rows until they match the number of cells in the header row.

I'm adding this as a draft PR for now since I need some guidance around the test suite:

Right now, I've changed the markdown example specs to conform to the new behavior and made the new behavior the default. Ideally, we'd have tests for both, the current and the new behavior - I just don't know how to do this. Does the markdown spec notation allow us to specify certain options to be used for the MarkdownPipeline?


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/xoofx/markdig/pull/455 **Author:** [@hamvocke](https://github.com/hamvocke) **Created:** 7/30/2020 **Status:** ✅ Merged **Merged:** 7/30/2020 **Merged by:** [@xoofx](https://github.com/xoofx) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (5) - [`8fa4742`](https://github.com/xoofx/markdig/commit/8fa47427ac0c55a46e4789aeebd572125902339d) change test for pipe table normalization - [`0eab0a3`](https://github.com/xoofx/markdig/commit/0eab0a310776f6d82a7d7cdc62593d826cf76fd6) set up example006 of pipe table spec according to new behavior - [`be53e77`](https://github.com/xoofx/markdig/commit/be53e778bed100a3d1269abc31085c612e5cc713) remove extra cells, use header row to find maxColumn - [`4390ff2`](https://github.com/xoofx/markdig/commit/4390ff289e836795fa6c166b23c178ce40ada190) add option to PipeTableOptions, use for normalization - [`cb0b3a6`](https://github.com/xoofx/markdig/commit/cb0b3a62925a7204e5ae3de43085fd6e1829b888) add 'gfm-pipetables' pipeline mode, introduce new gfm test spec ### 📊 Changes **9 files changed** (+1541 additions, -7 deletions) <details> <summary>View changed files</summary> ➕ `src/Markdig.Tests/Specs/PipeTableGfmSpecs.generated.cs` (+857 -0) ➕ `src/Markdig.Tests/Specs/PipeTableGfmSpecs.md` (+617 -0) 📝 `src/Markdig.Tests/Specs/PipeTableSpecs.generated.cs` (+1 -1) 📝 `src/Markdig.Tests/Specs/PipeTableSpecs.md` (+1 -1) 📝 `src/Markdig/Extensions/Tables/PipeTableOptions.cs` (+13 -1) 📝 `src/Markdig/Extensions/Tables/PipeTableParser.cs` (+8 -1) 📝 `src/Markdig/Extensions/Tables/Table.cs` (+39 -2) 📝 `src/Markdig/MarkdownExtensions.cs` (+4 -1) 📝 `src/SpecFileGen/Program.cs` (+1 -0) </details> ### 📄 Description This is a potential fix for #454. In this PR I'm introducing `PipeTableOptions.UseHeaderForColumnCount`, an option that allows switching the PipeTables extension's normalization behavior. It's defaulting to the current behavior (find the row with the most columns and make sure all other rows have the same amount of cells). When setting this option to `true`, the normalization will follow the [example in GitHub's spec](https://github.github.com/gfm/#example-202) and remove/add cells in all rows until they match the number of cells in the header row. I'm adding this as a draft PR for now since I need some guidance around the test suite: Right now, I've changed the markdown example specs to conform to the new behavior and made the new behavior the default. Ideally, we'd have tests for both, the current and the new behavior - I just don't know how to do this. Does the markdown spec notation allow us to specify certain options to be used for the `MarkdownPipeline`? --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 14:48:57 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#1042