diff --git a/php-transformer/src/HtmlToBlocks/HtmlTransformer.php b/php-transformer/src/HtmlToBlocks/HtmlTransformer.php index f2d6418..4b3b0f5 100644 --- a/php-transformer/src/HtmlToBlocks/HtmlTransformer.php +++ b/php-transformer/src/HtmlToBlocks/HtmlTransformer.php @@ -1098,7 +1098,7 @@ private function presentationAttributes(DOMElement $element): array return array_filter(array( 'className' => $this->promotedClassName($this->attr($element, 'class')), 'style' => $style, - 'layout' => $this->layoutAttribute($element), + 'layout' => $this->layoutAttribute($element, $style), ), static fn ($value): bool => is_array($value) ? array() !== $value : '' !== trim((string) $value)); } @@ -1137,7 +1137,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|grid|columns|layout|stack|cluster|row|wrap)(?:[^a-z0-9]|$)/', $tokens) ) { + if ( preg_match('/(?:^|[^a-z0-9])(?:btn|button|cta|action|nav|menu|cards?|tile|panel|pricing|price|product|grid|columns|layout|stack|cluster|row|wrap)(?:[^a-z0-9]|$)/', $tokens) ) { return true; } @@ -1403,7 +1403,7 @@ private function promotedClassName(string $className): string /** * @return array */ - private function layoutAttribute(DOMElement $element): array + private function layoutAttribute(DOMElement $element, string $mergedStyle = ''): array { $declared = trim($this->attr($element, 'data-layout')); if ( '' === $declared ) { @@ -1418,7 +1418,7 @@ private function layoutAttribute(DOMElement $element): array } } - $style = strtolower($this->attr($element, 'style')); + $style = strtolower('' !== trim($mergedStyle) ? $mergedStyle : $this->attr($element, 'style')); if ( preg_match('/(?:^|;)\s*display\s*:\s*(inline-)?flex\b/', $style) ) { return array( 'type' => 'flex' ); } 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 index 15f2fab..2b73cd2 100644 --- 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 @@ -18,12 +18,12 @@ { "path": "index.html", "kind": "html", - "content": "Layout wrappers

Plan the work

Keep the lead and aside aligned.

1

First shift

Flexible card row.

" + "content": "Layout wrappers

Plan the work

Keep the lead and aside aligned.

1

First shift

Flexible card row.

One

First service.

Two

Second service.

Three

Third service.

" }, { "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}" + "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}.services-cards{display:flex;gap:24px;align-items:stretch}" } ] } @@ -34,6 +34,7 @@ { "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": "serialized_blocks", "assert": "contains", "value": "" }, { "path": "fallbacks", "assert": "count", "count": 0 } ] }