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
4 changes: 3 additions & 1 deletion php-transformer/src/HtmlToBlocks/Patterns/ColumnsPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ private function looksLikeColumnsContainer(DOMElement $element): bool
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)
|| ( $this->looksLikeSplitLayout($element) && 1 < $this->directElementChildCount($element) )
|| ( $this->looksLikeSplitLayout($element) && 2 === $this->directElementChildCount($element) )
|| ( $this->looksLikeDocumentationLayout($element) && $this->hasSidebarAndContentChildren($element) )
|| preg_match('/(?:^|;)\s*(?:display\s*:\s*(?:inline-)?flex|grid-template-columns\s*:)/', $style);
}
Expand Down
7 changes: 7 additions & 0 deletions php-transformer/tests/unit/block-style-support-conversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
$assert(! str_contains($groupInnerHtml, 'gap:1rem'), '13: rendered wrapper omits blockGap when the core save shape does not reproduce it', $groupInnerHtml);
$assert(! str_contains($groupInnerHtml, 'display:flex') && ! str_contains($groupInnerHtml, 'justify-content:center'), '14: rendered wrapper does not carry raw flex declarations', $groupInnerHtml);

$stackHtml = '<div class="hero-content"><p>Eyebrow</p><h1>Low Tide Table</h1><div></div><p>Local shrimp.</p><div><p>Next Run</p></div><div><a href="#reserve">Reserve</a></div></div>';
$stackResult = ( new HtmlTransformer() )->transform($stackHtml, array())->toArray();
$stack = $stackResult['blocks'][0] ?? array();

$assert('core/group' === ($stack['blockName'] ?? ''), '15: multi-child hero content stack stays a group, not columns', (string) ($stack['blockName'] ?? '(none)'));
$assert('hero-content' === (($stack['attrs']['className'] ?? '')), '16: multi-child hero content stack keeps source class for stylesheet materialization', json_encode($stack['attrs'] ?? array()));

if ( $failures > 0 ) {
fwrite(STDERR, "Block style support conversion tests: {$failures} failed, {$passes} passed\n");
exit(1);
Expand Down
Loading