From 17745ad4d285c514809a32a16ddd14336236b485 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Sun, 17 May 2026 18:51:11 -0400 Subject: [PATCH] Refresh vendored HTML converter --- composer.lock | 8 +++--- .../includes/class-transform-registry.php | 28 ++++++++++++++++++- .../tests/smoke-branded-link-spans.php | 2 ++ .../smoke-repeated-card-grid-transforms.php | 1 + 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 758e980..f7417cd 100644 --- a/composer.lock +++ b/composer.lock @@ -726,12 +726,12 @@ "source": { "type": "git", "url": "https://github.com/chubes4/html-to-blocks-converter.git", - "reference": "3a99837c5e3aa5188475a0704ed596680b624684" + "reference": "d8b6ce830884e96d36cdcadb2367d886db3426c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/chubes4/html-to-blocks-converter/zipball/3a99837c5e3aa5188475a0704ed596680b624684", - "reference": "3a99837c5e3aa5188475a0704ed596680b624684", + "url": "https://api.github.com/repos/chubes4/html-to-blocks-converter/zipball/d8b6ce830884e96d36cdcadb2367d886db3426c7", + "reference": "d8b6ce830884e96d36cdcadb2367d886db3426c7", "shasum": "" }, "require": { @@ -759,7 +759,7 @@ "source": "https://github.com/chubes4/html-to-blocks-converter/tree/main", "issues": "https://github.com/chubes4/html-to-blocks-converter/issues" }, - "time": "2026-05-17T22:30:08+00:00" + "time": "2026-05-17T22:50:13+00:00" }, { "name": "fidry/console", diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/includes/class-transform-registry.php b/vendor_prefixed/chubes4/html-to-blocks-converter/includes/class-transform-registry.php index 1769827..c8ac1b3 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/includes/class-transform-registry.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/includes/class-transform-registry.php @@ -944,7 +944,31 @@ private static function is_numeric_label_span($element): bool */ private static function create_inline_span_label_paragraph($element): array { - return HTML_To_Blocks_Block_Factory::create_block('core/paragraph', array('content' => \trim($element->get_outer_html()))); + $attributes = array('content' => \trim($element->get_outer_html())); + self::apply_inline_preservation_paragraph_spacing($attributes); + return HTML_To_Blocks_Block_Factory::create_block('core/paragraph', $attributes); + } + /** + * Removes default paragraph margins from paragraphs standing in for inline markup. + * + * @param array $attributes Paragraph block attributes. + */ + private static function apply_inline_preservation_paragraph_spacing(array &$attributes): void + { + if (!isset($attributes['style']) || !\is_array($attributes['style'])) { + $attributes['style'] = array(); + } + if (!isset($attributes['style']['spacing']) || !\is_array($attributes['style']['spacing'])) { + $attributes['style']['spacing'] = array(); + } + if (!isset($attributes['style']['spacing']['margin']) || !\is_array($attributes['style']['spacing']['margin'])) { + $attributes['style']['spacing']['margin'] = array(); + } + foreach (array('top', 'right', 'bottom', 'left') as $side) { + if (!isset($attributes['style']['spacing']['margin'][$side])) { + $attributes['style']['spacing']['margin'][$side] = '0'; + } + } } /** * Checks whether an aria-hidden div is only inline span labels. @@ -998,6 +1022,7 @@ private static function is_visual_diagram_span_container($element): bool private static function create_aria_hidden_inline_span_paragraph($element): array { $attributes = self::get_block_support_attributes($element, array('anchor' => \true, 'class_name' => \true, 'colors' => \true, 'typography' => \true, 'spacing' => \true, 'border' => \true)); + self::apply_inline_preservation_paragraph_spacing($attributes); $attributes['content'] = \trim($element->get_inner_html()); return HTML_To_Blocks_Block_Factory::create_block('core/paragraph', $attributes); } @@ -1047,6 +1072,7 @@ private static function is_branded_inline_anchor($element): bool private static function create_branded_inline_anchor_paragraph($element): array { $attributes = self::get_block_support_attributes($element, array('anchor' => \true)); + self::apply_inline_preservation_paragraph_spacing($attributes); $attributes['content'] = \trim($element->get_outer_html()); return HTML_To_Blocks_Block_Factory::create_block('core/paragraph', $attributes); } diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-branded-link-spans.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-branded-link-spans.php index 396ed25..916c11c 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-branded-link-spans.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-branded-link-spans.php @@ -137,6 +137,7 @@ function serialize_blocks(array $blocks): string $assert(!\str_contains($aria_hidden_span_ruler, ''), 'aria-hidden-span-ruler-avoids-core-html', $aria_hidden_span_ruler); $assert(\str_contains($aria_hidden_span_ruler, ''), 'visible-diagram-span-container-avoids-core-html', $visible_diagram_span_group); $assert(\str_contains($visible_diagram_span_group, '