diff --git a/php-transformer/src/HtmlToBlocks/Patterns/ColumnsPattern.php b/php-transformer/src/HtmlToBlocks/Patterns/ColumnsPattern.php index 02aa4c0a..f8ecca89 100644 --- a/php-transformer/src/HtmlToBlocks/Patterns/ColumnsPattern.php +++ b/php-transformer/src/HtmlToBlocks/Patterns/ColumnsPattern.php @@ -108,12 +108,17 @@ private function looksLikeColumnsContainer(DOMElement $element, string $resolved // vertical stack. Emitting core/columns would render them horizontally — // the wrong direction. Decline here so the host transformer routes the // element to a vertical core/group instead, preserving its classes and - // styles. Horizontal flex (row / row-reverse / default) and grid layouts - // are unaffected, so legitimate horizontal columns are never disturbed. + // styles. Horizontal flex (row / row-reverse / default) remains eligible. if ( $this->isVerticalFlexContainer($style) ) { return false; } + // core/columns is a flex layout. Preserve resolved grid containers as + // groups so their source classes continue to control track geometry. + if ( preg_match('/(?:^|;)\s*display\s*:\s*(?:inline-)?grid\b/', $style) ) { + return false; + } + // Split-layout names describe two-pane structures. Multi-child content // stacks such as hero copy must stay groups so source CSS controls flow. return (bool) preg_match('/(?:^|[\s_-])columns?(?:$|[\s_-])/', $className) 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 dfba5d77..79296c20 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 @@ -1,11 +1,11 @@ { "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.", + "description": "Applies safe visual declarations from linked class CSS while preserving grid and flex wrapper semantics.", "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." + "notes": "Covers layout wrapper class CSS used by generated static HTML fixtures, including source grid containers that must not become flex-based Columns blocks." }, "legacy_comparison": { "skip": true, @@ -31,8 +31,9 @@ "expect": [ { "path": "status", "assert": "equals", "value": "success" }, { "path": "serialized_blocks", "assert": "contains", "value": "hero-grid" }, - { "path": "serialized_blocks", "assert": "contains", "value": "" }, - { "path": "serialized_blocks", "assert": "contains", "value": "
" }, + { "path": "serialized_blocks", "assert": "contains", "value": "" }, + { "path": "serialized_blocks", "assert": "contains", "value": "
" }, + { "path": "serialized_blocks", "assert": "not_contains", "value": "" }, { "path": "serialized_blocks", "assert": "contains", "value": "
" }, diff --git a/php-transformer/tests/fixtures/parity/html-resolved-split-grid-stays-group.json b/php-transformer/tests/fixtures/parity/html-resolved-split-grid-stays-group.json new file mode 100644 index 00000000..097b47fd --- /dev/null +++ b/php-transformer/tests/fixtures/parity/html-resolved-split-grid-stays-group.json @@ -0,0 +1,30 @@ +{ + "schema": "blocks-engine/php-transformer/parity-fixture/v1", + "name": "html-resolved-split-grid-stays-group", + "description": "A two-child split container resolved as CSS grid stays a core/group so source grid tracks and alignment are not replaced by Gutenberg Columns flex geometry.", + "source_reference": { + "repo": "php-transformer", + "path": "tests/fixtures/parity/html-resolved-split-grid-stays-group.json", + "notes": "Uses a generic split-layout class that the columns recognizer accepts without resolved-style awareness. The resolved CSS grid must take precedence over the class-name heuristic." + }, + "legacy_comparison": { + "skip": true, + "reason": "Covers current PHP transformer resolved-layout behavior; no downstream legacy comparison." + }, + "operation": "html_transformer.transform", + "input": { + "content": "

Fast setup

Start with a stable foundation.

Preview

" + }, + "expected_blocks": [ + { "path": "blocks.0", "name": "core/group", "attrs": { "className": "feature-row" } }, + { "path": "blocks.0.innerBlocks.0", "name": "core/group", "attrs": { "className": "feature-copy" } }, + { "path": "blocks.0.innerBlocks.1", "name": "core/group", "attrs": { "className": "feature-visual" } } + ], + "expected_fallbacks": [], + "expect": [ + { "path": "status", "assert": "equals", "value": "success" }, + { "path": "serialized_blocks", "assert": "contains", "value": "