feat(shortcodes): add caption argument to table shortcode#2030
Draft
LeonarddeR wants to merge 2 commits into
Draft
feat(shortcodes): add caption argument to table shortcode#2030LeonarddeR wants to merge 2 commits into
LeonarddeR wants to merge 2 commits into
Conversation
Add a `caption` argument to the table shortcode that renders an HTML `<caption>` element, plus an opt-in `caption-top` boolean (default false). The caption is injected as the table's last child, before `</table>`, the same position simple-datatables re-appends it to, so a plain and a data table share identical DOM. Bottom is the native default of both Bootstrap and simple-datatables; `caption-top=true` adds Bootstrap's `.caption-top` class to move it above via CSS `caption-side`, independent of DOM order. Safelist `caption-top` in both PostCSS configs: it is emitted only under the opt-in, so a site that never renders it would otherwise have the `.caption-top` rule purged, leaving the option inert. Closes gethinode#1690 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
👷 Deploy request for gethinode-demo pending review.Visit the deploys page to approve it
|
Cut rationale/history from PurgeCSS safelist, table partial, and argument comments; keep only how-focused notes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Adds a
captionargument to thetableshortcode that renders an HTML<caption>element, plus an opt-incaption-topboolean. Closes #1690.Behavior
{{< table caption="Overview of records" >}} | Name | Type | |-------|--------| | alpha | widget | {{< /table >}}The
<caption>is injected as the table's last child, just before</table>— the same positionsimple-datatablesre-appends it to, so a plain table and a data table share identical DOM.captioninherits the existing globalstringargument definition (comment overridden for the table context).Position
caption-topdefaults tofalse. Bottom is the native default of both Bootstrap and simple-datatables, so it's the least-surprising default;caption-top="true"adds Bootstrap's.caption-topclass, moving the caption above the table via CSScaption-side— independent of DOM order.PurgeCSS safelist
caption-topis emitted only under the opt-in, so on a site that never renders it the.caption-top{caption-side:top}rule would be purged from the compiled CSS, leaving the option silently inert. It's added to thestandardsafelist in bothconfig/postcss.config.jsandexampleSite/config/postcss.config.js— the same class of issue as the already-safelistedtable-wrap/d-*-table-cell.Verification
Built the example site and drove it in a browser. With no
caption-top, the caption renders below the table (caption-side: bottom, last child); withcaption-top="true"it flips to top (caption-side: top). Confirmed the.caption-toprule survives PurgeCSS after safelisting (it was purged, and the opt-in had no effect, before). Verified simple-datatables preserves the server-rendered<caption>on data tables (it capturesCAPTIONnodes on init and re-appends them on render). A caption fixture is added to thetable-demopage. Existing table fixtures are unaffected;pnpm lintpasses.🤖 Generated with Claude Code