Collapse typography-only text wrappers to styled paragraphs (#630)#684
Merged
Conversation
A styled `<div>`/`<span>` whose only content is inline text and whose CSS is typographic (no box-model geometry) was round-tripped as a `core/group` wrapping a default `core/paragraph`. That form does not inherit the wrapper's typographic scale onto the inner paragraph and does not suppress default block spacing, so an eyebrow like `<div class="label">The Shop</div>` rendered at the wrong font size and introduced a ~21px top offset that shifted every following block down the page (visible across imported artist-site routes). visualTextWrapperBlockFromElement now emits a single styled `core/paragraph` carrying the wrapper class when the wrapper is a pure-text leaf with no box-model styling (padding/border/explicit sizing/flex-grid). Wrappers that own box-model geometry (`.tag`, `.tier-price`, `.use-case-result`) still round-trip as `core/group` so their block-level layout is preserved. Box-model detection reads the raw matched declarations via structuralPresentationDeclarations so padding consumed into block-supports attributes is still seen. Updates block-style-support conversion tests: box-model wrappers stay groups; the typography-only `.tier-name` label now collapses to a styled paragraph. Full php-transformer suite green: 248 parity fixtures, 75 block-style-support tests, wordpress-site-plan + shared-shell-plan contracts. Refs #630. AI assistance: drafted with Claude (Sonnet 4.5) via opencode; DOM-snapshot root-cause and implementation reviewed by Chris Huber.
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
A styled
<div>/<span>whose only content is inline text and whose CSS is typographic (font-size, letter-spacing, text-transform, color — no box-model geometry) was round-tripped as acore/groupwrapping a defaultcore/paragraph. That structure has two defects:.label{font-size:0.68rem}) applies to the group<div>, but the inner default paragraph renders at the theme's base paragraph size instead of inheriting the wrapper's scale.margin-top, adding vertical space the source never had.On imported artist-site routes, an eyebrow like
<div class="label">The Shop</div>rendered at the wrong size and injected a uniform ~21px top offset that shifted every following block down the page (measured:page-headerinflated 458.6px → 479.7px;merch-intro/grid/footer all shifted +21px with no accumulation).Fix
visualTextWrapperBlockFromElement()now emits a single styledcore/paragraphcarrying the wrapper class when the wrapper is a pure-text leaf (no child elements) with no box-model styling. Wrappers that own box-model geometry — padding, border, explicit sizing, or flex/grid layout (.tag,.tier-price,.use-case-result) — still round-trip ascore/groupso their block-level layout is preserved.Box-model detection reads the raw matched declarations via
structuralPresentationDeclarations()rather than the post-projection presentation set, so padding consumed into block-supports attributes is still seen.Verification
Proven directly against the real fixture —
fixtures/websites/3-artist-music/merch.htmlnow compiles the eyebrow as:Full
php-transformersuite green:.tier-namenow collapses to a styled paragraph)wordpress-site-plan+shared-shell-plancontracts, HTML-to-blocks contractThe block-style-support tests were updated to encode the corrected contract: box-model wrappers stay
core/group; typography-only text wrappers collapse to styled paragraphs.AI assistance disclosure
Drafted with Claude (Sonnet 4.5) via opencode, used to root-cause the offset from DOM snapshots and implement the box-model-aware collapse. Every line reviewed by Chris Huber.
Refs #630.