Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions php-transformer/src/HtmlToBlocks/Patterns/ColumnsPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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": "<!-- wp:columns {\"className\":\"hero-grid\"} -->" },
{ "path": "serialized_blocks", "assert": "contains", "value": "<div class=\"wp-block-columns hero-grid\">" },
{ "path": "serialized_blocks", "assert": "contains", "value": "<!-- wp:group {\"className\":\"hero-grid\",\"tagName\":\"section\"} -->" },
{ "path": "serialized_blocks", "assert": "contains", "value": "<section class=\"wp-block-group hero-grid\">" },
{ "path": "serialized_blocks", "assert": "not_contains", "value": "<!-- wp:columns {\"className\":\"hero-grid\"}" },
{ "path": "serialized_blocks", "assert": "contains", "value": "shift-card" },
{ "path": "serialized_blocks", "assert": "contains", "value": "<!-- wp:group {\"className\":\"shift-card\",\"tagName\":\"section\"} -->" },
{ "path": "serialized_blocks", "assert": "contains", "value": "<section class=\"wp-block-group shift-card\">" },
Expand Down
Original file line number Diff line number Diff line change
@@ -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": "<section class=\"feature-row\" style=\"display:grid;grid-template-columns:520px 520px;gap:64px;align-items:center\"><div class=\"feature-copy\"><h2>Fast setup</h2><p>Start with a stable foundation.</p></div><div class=\"feature-visual\"><p>Preview</p></div></section>"
},
"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": "<!-- wp:group {\"className\":\"feature-row\"" },
{ "path": "serialized_blocks", "assert": "not_contains", "value": "<!-- wp:columns" },
{ "path": "fallbacks", "assert": "count", "count": 0 }
]
}
Loading