Add {table} directive with column width support#2684
Open
theletterf wants to merge 12 commits intomainfrom
Open
Add {table} directive with column width support#2684theletterf wants to merge 12 commits intomainfrom
{table} directive with column width support#2684theletterf wants to merge 12 commits intomainfrom
Conversation
Introduce a MyST `{table}` directive that allows authors to control table
column widths using a `:widths:` option (e.g., `:widths: 30 70`). Values
are normalized to percentages and rendered as `<colgroup>`/`<col>` elements
with `table-layout: fixed` CSS. Also supports an optional caption via the
directive argument.
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
🔍 Preview links for changed docs |
Address code quality review comments by casting the sequence at enumeration level rather than inside the loop body. Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Cover additional validation paths: zero width values, decimal width
values rejected by int parsing, and non-table content wrapped in the
{table} directive emitting a warning.
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Set ImplicitParagraph = true when rendering cell content in the custom colgroup renderer, matching Markdig's base HtmlTableRenderer behavior. Without this, cell content was wrapped in <p> tags, adding unwanted margin to header and body cells. Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Extract shared width parsing logic into WidthsParser helper, reused by
both {table} and {csv-include} directives. The CSV include Razor view
now renders <colgroup>/<col> elements with table-layout: fixed when
widths are specified. Also fix caption markup to use <div> instead of
misplaced <caption> outside <table>.
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Member
|
#2686 might impact this since it includes my upstream changes to markdig which changes the table AST. Lets merge that one first and then update this PR. |
Contributor
Author
The caption div was inside the overflow scroll container, causing it to
be squeezed by the fixed-width table layout. Move it before the wrapper
to match the {table} directive's rendering and the existing CSS rule
for .table-caption + .table-wrapper.
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Tailwind defines a `table-caption` utility that sets `display: table-caption`, which caused our caption element to shrink to min-content width and wrap each word vertically. Rename the class to `md-table-caption` and update CSS, renderers, and tests. Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
@elastic/docs-tech-leads @KOTungseth Green light to get this one in? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
{table}directive that allows authors to control table column widths using a:widths:option with space-separated relative integers (e.g.,:widths: 30 70), normalized to percentages and rendered via<colgroup>/<col>withtable-layout: fixedCSS.:::{table} My caption).WrappedTableRendererto manually render<colgroup>and column width styles when custom widths are present, since Markdig's defaultHtmlTableRendererdoes not emit them.:widths:support to the{csv-include}directive, with shared parsing logic extracted into aWidthsParserhelper.docs/syntax/tables.mdanddocs/syntax/csv-include.mdwith practical examples.Closes https://github.com/elastic/docs-eng-team/issues/424