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:----ifyctmmKkjK4B0n6FAogpbcQZ8VfNrcrHg86HNzfxHwBxQeL8zA8qV4oi32vFLSyQsiFG0ZbGs+3bR7hSseoaljDCW+MGxwH7RLhZS5kB6vOMy3VCXwB5AtAXsCHkEbE1cIbv40pJuM7PbyF6Rt6ltLtQI8YZi1uCpekq99swjMAQmLFrPMQ8puYrIcynYbJfhfTa0gsFg0Hw/dmbQau9Nlr0FuNUs66I9r194ndfPflJvl3qGxLfK6hnHka5f4TCK0Bz83lyLqZcsVzy+jLyQCOXtOXYr90BrZ+KsOYzaHjJPHqGpm40sNp6dFOv5B3i/bUqUzJZREvQ4X+g12e24hFDM3KDUmsFWcZaE/VSyUREQkdcU7s0GMid5iOWC2a4Q3B2kMbE1X7NS7pgb/PYe8zrdPDXmf7daEm0OcUxzfnQr2413RbqxIcagiM1Azf7nfMt/4xJPxVezLp+ctmWgf3TlXCdRawQQXL3UjQFhpV9roMlPFTujcpWHT/Gl4ll/aPgsDs+6Fe2JV0Akb9yh/5pDRPaA9MHpwY+PbVBB1fwQnTKH9i1USZglQUDYrfbavXIfaqNa3Yh1iDYtihPnzNnoywQOzv6wXQYc3lsCn5DEGWxkxNm6+bc7quDU0PjD87ffoc+qFvt/pCB3rMdM7U5FQ+po3FulSFFwggC0w=----ATTACHMENT:----NjkyMDI2NDg4MDcyMzIzNyA4MjkyNzIxMzMxNTkzMzcyIDUxOTU0ODY2Nzc5ODAxNTE=