From 5cf210c8d1aceef7ebbce215f14bd51a40cdfc49 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Tue, 23 Jun 2026 23:34:06 -0400 Subject: [PATCH] Preserve linked CSS layout wrapper styles --- .../src/HtmlToBlocks/HtmlTransformer.php | 10 ++++- ...nked-css-layout-wrapper-style-signals.json | 39 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 php-transformer/tests/fixtures/parity/artifact-linked-css-layout-wrapper-style-signals.json diff --git a/php-transformer/src/HtmlToBlocks/HtmlTransformer.php b/php-transformer/src/HtmlToBlocks/HtmlTransformer.php index 8803f85..afaf408 100644 --- a/php-transformer/src/HtmlToBlocks/HtmlTransformer.php +++ b/php-transformer/src/HtmlToBlocks/HtmlTransformer.php @@ -1062,7 +1062,7 @@ private function isHighValueStyledElement(DOMElement $element): bool $this->attr($element, 'role'), )))); - if ( preg_match('/(?:^|[^a-z0-9])(?:btn|button|cta|action|nav|menu|card|tile|panel|pricing|price|product)(?:[^a-z0-9]|$)/', $tokens) ) { + if ( preg_match('/(?:^|[^a-z0-9])(?:btn|button|cta|action|nav|menu|card|tile|panel|pricing|price|product|grid|columns|layout|stack|cluster|row|wrap)(?:[^a-z0-9]|$)/', $tokens) ) { return true; } @@ -1133,10 +1133,17 @@ private function safeVisualDeclarations(array $declarations): array 'border-width', 'box-shadow', 'color', + 'align-items', + 'column-gap', 'display', + 'flex-direction', + 'flex-wrap', 'font-size', 'font-weight', 'gap', + 'grid-template-columns', + 'grid-template-rows', + 'justify-content', 'line-height', 'margin', 'margin-bottom', @@ -1148,6 +1155,7 @@ private function safeVisualDeclarations(array $declarations): array 'padding-left', 'padding-right', 'padding-top', + 'row-gap', 'text-align', 'text-decoration', 'text-transform', diff --git a/php-transformer/tests/fixtures/parity/artifact-linked-css-layout-wrapper-style-signals.json b/php-transformer/tests/fixtures/parity/artifact-linked-css-layout-wrapper-style-signals.json new file mode 100644 index 0000000..15f2fab --- /dev/null +++ b/php-transformer/tests/fixtures/parity/artifact-linked-css-layout-wrapper-style-signals.json @@ -0,0 +1,39 @@ +{ + "schema": "blocks-engine/php-transformer/parity-fixture/v1", + "name": "artifact-linked-css-layout-wrapper-style-signals", + "description": "Applies safe visual declarations from linked class CSS to generic grid and flex layout wrappers.", + "source_reference": { + "repo": "php-transformer", + "path": "tests/fixtures/parity/artifact-linked-css-layout-wrapper-style-signals.json", + "notes": "Covers layout wrapper class CSS used by generated static HTML fixtures, such as grid columns and flexible card rows." + }, + "legacy_comparison": { + "skip": true, + "reason": "This upstream CSS layout signal fixture has no downstream legacy comparison." + }, + "operation": "artifact_compiler.compile", + "input": { + "artifact": { + "files": [ + { + "path": "index.html", + "kind": "html", + "content": "Layout wrappers

Plan the work

Keep the lead and aside aligned.

1

First shift

Flexible card row.

" + }, + { + "path": "assets/site.css", + "kind": "css", + "content": ".hero-grid{display:grid;grid-template-columns:1fr 420px;gap:clamp(24px,4vw,64px);align-items:center}.shift-card{display:grid;grid-template-columns:auto 1fr;gap:16px;align-items:start}" + } + ] + } + }, + "expect": [ + { "path": "status", "assert": "equals", "value": "success" }, + { "path": "serialized_blocks", "assert": "contains", "value": "hero-grid" }, + { "path": "serialized_blocks", "assert": "contains", "value": "display:grid;grid-template-columns:1fr 420px;gap:clamp(24px,4vw,64px);align-items:center" }, + { "path": "serialized_blocks", "assert": "contains", "value": "shift-card" }, + { "path": "serialized_blocks", "assert": "contains", "value": "display:grid;grid-template-columns:auto 1fr;gap:16px;align-items:start" }, + { "path": "fallbacks", "assert": "count", "count": 0 } + ] +}