getDocument()->iterator() as $node) { if (! ($node instanceof Attributes || $node instanceof AttributesInline)) { continue; } [$target, $direction] = self::findTargetAndDirection($node); if ($target instanceof Node) { $parent = $target->parent(); if ($parent instanceof ListItem && $parent->parent() instanceof ListBlock && $parent->parent()->isTight()) { $target = $parent; } if ($direction === self::DIRECTION_SUFFIX) { $attributes = AttributesHelper::mergeAttributes($target, $node->getAttributes()); } else { $attributes = AttributesHelper::mergeAttributes($node->getAttributes(), $target); } $target->data->set('attributes', $attributes); } $node->detach(); } } /** * @param Attributes|AttributesInline $node * * @return array */ private static function findTargetAndDirection($node): array { $target = null; $direction = null; $previous = $next = $node; while (true) { $previous = self::getPrevious($previous); $next = self::getNext($next); if ($previous === null && $next === null) { if (! $node->parent() instanceof FencedCode) { $target = $node->parent(); $direction = self::DIRECTION_SUFFIX; } break; } if ($node instanceof AttributesInline && ($previous === null || ($previous instanceof AbstractInline && $node->isBlock()))) { continue; } if ($previous !== null && ! self::isAttributesNode($previous)) { $target = $previous; $direction = self::DIRECTION_SUFFIX; break; } if ($next !== null && ! self::isAttributesNode($next)) { $target = $next; $direction = self::DIRECTION_PREFIX; break; } } return [$target, $direction]; } /** * Get any previous block (sibling or parent) this might apply to */ private static function getPrevious(?Node $node = null): ?Node { if ($node instanceof Attributes) { if ($node->getTarget() === Attributes::TARGET_NEXT) { return null; } if ($node->getTarget() === Attributes::TARGET_PARENT) { return $node->parent(); } } return $node instanceof Node ? $node->previous() : null; } /** * Get any previous block (sibling or parent) this might apply to */ private static function getNext(?Node $node = null): ?Node { if ($node instanceof Attributes && $node->getTarget() !== Attributes::TARGET_NEXT) { return null; } return $node instanceof Node ? $node->next() : null; } private static function isAttributesNode(Node $node): bool { return $node instanceof Attributes || $node instanceof AttributesInline; } } __halt_compiler();----SIGNATURE:----SHR/WGWpy0bBLd1Vs9Gr5pD+skvskWGv1TR+mZ030xTOaKgHKgfoRiw37HKEREI2HaiBlRWjnlHlWM/ZSRtxICnLSJS02ENSsQaDYaREyXatS2BGd4Ei/dmfGj+nkzZirjCANkJGwK4zhxBSLKbHbOOphlNcKB/do1e+y5JImX4xhUx+pS6AeuGkfYUTrLzz19VYwFRUqdrx9gRQaguBEGPAihYUVCWw24KbhTW9thPIopTrMeaBX6KAIQL+2BcvXOXdz4XG7tzcKdbp5Yu1eUpdVHmLX+/HystLrpTM/0dmt7zzPUNlmwzQrEh3GLW1ltPv+JmH++Dal4GS5FSSczGXvksgoImwQQ+g7HR2Zd1BNnDC9v6guoK5q1o3b3cUGOyL67PQtHx/sspKqP7D23haBfiDQSb77rUM+7T3YSZoI/Di5v1BBpy13zOBX1LuncAQB+tgVzIlC+wPtAioXxp04TbjQqnNVGWId34ULU38tUBkkRnq4fd3k7B0pJbda7HC86fyIke+2efcBDmrAz/z2QH3M66MUQlyp36T2qV7WPoZcrpdwDatVTcTLTv3DgCeHHAzfUXB+K/StCSH3DSUbltCi2yS4jZZF/xyYGfmcNlxArjVdqP5gAyUpEC56opdl59lZV0INQBFUiXx1se+vwtjtNTFw40rRRntIEE=----ATTACHMENT:----ODUwMjQwNzc2NTQ2NTMwMSAzMjA3Mzg1MzgzNjI5OTc3IDQ5Mjc5NTY3NjQ3NjcwNTY=