Skip to content

Honor Markdown pipe-table column alignment in ConsoleTableRenderer#143

Merged
boxofyellow merged 4 commits into
mainfrom
copilot/markdig-spectre-console-honor-column-alignment
May 17, 2026
Merged

Honor Markdown pipe-table column alignment in ConsoleTableRenderer#143
boxofyellow merged 4 commits into
mainfrom
copilot/markdig-spectre-console-honor-column-alignment

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 16, 2026

Markdig's pipe-table extension records per-column alignment in Table.ColumnDefinitions[i].Alignment, but ConsoleRendererBase.TableFrame was constructing Spectre.Console TableColumns without it, so every column rendered left-aligned regardless of :---, :---:, or ---: in the source.

Changes

  • ObjectRenderers/Frames/ConsoleRendererBase.TableFrame.cs: In the column-creation branch of AddRow, map TableColumnAlign to Justify and assign it to the new TableColumn. A bounds check covers the case where ColumnDefinitions is shorter than the widest row.
  • Tests: Added RendererTests_TableColumnAlignment_HonorsMarkdownAlignment and ..._DefaultsToLeftWhenUnspecified that inspect renderer.Root's inner Spectre Table.Columns[i].Alignment directly (the existing TextValidation debug-mode output cannot show alignment because each cell is rendered as a nested Table, which Spectre always positions at the left of its parent cell). Also added a tableAlignment.md/.txt resource pair for regression coverage.
  • docs/CHANGELOG.md: Entry under Upcoming Changes.
column.Alignment = MDTable.ColumnDefinitions[i].Alignment switch
{
    TableColumnAlign.Center => Justify.Center,
    TableColumnAlign.Right  => Justify.Right,
    _                       => Justify.Left,
};

Copilot AI changed the title [WIP] Honor table column alignment in ConsoleTableRenderer Honor Markdown pipe-table column alignment in ConsoleTableRenderer May 16, 2026
Copilot AI requested a review from boxofyellow May 16, 2026 15:16
Copy link
Copy Markdown
Owner

@boxofyellow boxofyellow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot are you sure it is working?

Comment thread ConsoleMarkdownRenderer.Tests/resources/tableAlignment.txt Outdated
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 17, 2026

@copilot are you sure it is working?

Good catch — the original commit set TableColumn.Alignment but the visible cell content stayed left-flush because each cell is rendered as a nested Spectre Table (from the cell frame) and Spectre.Console doesn't apply parent column Justify to nested Table renderables. Fixed in fa4ee43 by also expanding the inner cell-frame table and aligning its single column. See the reply on the tableAlignment.txt thread for the before/after output.

Copilot AI requested a review from boxofyellow May 17, 2026 00:09
Comment thread docs/CHANGELOG.md Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

❌ Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.80%. Comparing base (20f15e5) to head (5f47530).

Files with missing lines Patch % Lines
...Renderers/Frames/ConsoleRendererBase.TableFrame.cs 94.73% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #143      +/-   ##
==========================================
- Coverage   95.82%   95.80%   -0.02%     
==========================================
  Files          30       30              
  Lines        1676     1694      +18     
  Branches      176      179       +3     
==========================================
+ Hits         1606     1623      +17     
  Misses         46       46              
- Partials       24       25       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread docs/CHANGELOG.md Outdated
Copilot AI and others added 4 commits May 16, 2026 20:47
Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
@boxofyellow boxofyellow force-pushed the copilot/markdig-spectre-console-honor-column-alignment branch from 32455cb to 5f47530 Compare May 17, 2026 00:47
@boxofyellow boxofyellow marked this pull request as ready for review May 17, 2026 00:52
@boxofyellow boxofyellow merged commit 0b36942 into main May 17, 2026
10 of 12 checks passed
@boxofyellow boxofyellow deleted the copilot/markdig-spectre-console-honor-column-alignment branch May 17, 2026 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Markdig/Spectre.Console] Honor table column alignment in ConsoleTableRenderer

2 participants