Skip to content

🐛 Stamp sd-card-text on direct paragraphs only, never replace classes#278

Merged
chrisjsewell merged 1 commit into
mainfrom
brief/09-card-text-classes
Jul 14, 2026
Merged

🐛 Stamp sd-card-text on direct paragraphs only, never replace classes#278
chrisjsewell merged 1 commit into
mainfrom
brief/09-card-text-classes

Conversation

@chrisjsewell

@chrisjsewell chrisjsewell commented Jul 12, 2026

Copy link
Copy Markdown
Member

Fixes two related bugs in how sd-card-text is applied to paragraphs in cards and dropdowns.

Changes

  • Dropdown transform no longer wipes user classes: an inverted conditional ([] if "classes" in para else para["classes"] — always true for docutils elements) meant every paragraph in every dropdown body had its existing classes replaced by ["sd-card-text"]. Any user class (e.g. via rst-class or MyST attrs) was silently destroyed. Now appends.
  • Stamping is limited to direct child paragraphs in both the dropdown transform and CardDirective.add_card_child_classes: previously all descendant paragraphs (inside nested admonitions, lists, nested tab-sets, …) were stamped, causing the spacing artefacts in Multi-line content in dropdown has extra spacing on first line #40. Nested content now renders with its natural spacing, consistent with the same content outside a card.

Verification

  • New tests/test_card_text.py (rst + myst): user-class preservation, direct-vs-nested stamping for card, dropdown, and grid-item-card (the delegated path), and the Multi-line content in dropdown has extra spacing on first line #40 two-paragraph reproduction. The regression cases were verified failing against the unfixed code.
  • Zero existing regression fixtures change: audited — existing fixtures only ever contained direct-child sd-card-text paragraphs (which is why Multi-line content in dropdown has extra spacing on first line #40 went undetected).
  • Shipped-docs impact audit: the only rendering delta across the whole docs build is two tab-panel paragraphs inside the "tabs in dropdown" example losing the class — provably pixel-identical, since .sd-tab-content>:last-child{margin-bottom:0 !important} already forces the same margin either way.
  • No CSS changes. Follow-up recorded for the card redesign: consider moving stamping to a CSS child selector entirely.

Closes #40

@chrisjsewell chrisjsewell force-pushed the brief/09-card-text-classes branch from 39dda57 to dc77a46 Compare July 12, 2026 17:46
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.42%. Comparing base (6e06c98) to head (525cda2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #278      +/-   ##
==========================================
+ Coverage   90.40%   90.42%   +0.01%     
==========================================
  Files          13       13              
  Lines        1147     1149       +2     
==========================================
+ Hits         1037     1039       +2     
  Misses        110      110              
Flag Coverage Δ
pytests 90.42% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The dropdown HTML transform had an inverted conditional that replaced,
rather than appended to, each body paragraph's classes, silently
destroying user-authored classes. Both cards and dropdowns also stamped
sd-card-text on every descendant paragraph via findall, applying card
typography to content nested inside admonitions, lists and nested
components (#40). Both sites now stamp direct child paragraphs only.
@chrisjsewell chrisjsewell force-pushed the brief/09-card-text-classes branch from dc77a46 to 525cda2 Compare July 14, 2026 10:18
@chrisjsewell chrisjsewell merged commit c0acc48 into main Jul 14, 2026
25 checks passed
@chrisjsewell chrisjsewell deleted the brief/09-card-text-classes branch July 14, 2026 15:21
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.

Multi-line content in dropdown has extra spacing on first line

1 participant