diff --git a/daux.phar b/daux.phar index d8992f7..457b9f7 100755 Binary files a/daux.phar and b/daux.phar differ diff --git a/generate b/generate index 0ec2d21..73cb4ef 100755 --- a/generate +++ b/generate @@ -64,8 +64,8 @@ software, even if advised of the possibility of such damage. */ -if (file_exists('vendor/autoload.php')) { - require_once('vendor/autoload.php'); +if (file_exists(__DIR__ . '/vendor/autoload.php')) { + require_once(__DIR__ . '/vendor/autoload.php'); } elseif (file_exists('daux.phar')) { define('PHAR_DIR', __DIR__); require_once("phar://" . __DIR__ . "/daux.phar/vendor/autoload.php"); diff --git a/libs/Compiler.php b/libs/Compiler.php index 443fde0..f00e1d1 100644 --- a/libs/Compiler.php +++ b/libs/Compiler.php @@ -105,13 +105,14 @@ class Compiler $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_files.php')); $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_namespaces.php')); $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_real.php')); - $staticAutoload = new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_static.php'); - if ($staticAutoload->isFile()) { - $this->addFile($phar, $staticAutoload); - } - $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/ClassLoader.php')); + if (file_exists(__DIR__ . '/../vendor/composer/autoload_static.php')) { + $content = file_get_contents(__DIR__ . '/../vendor/composer/autoload_static.php'); + $content = str_replace('__DIR__ . \'/../..\' . \'/daux\'', 'PHAR_DIR . \'/daux\'', $content); + $phar->addFromString('vendor/composer/autoload_static.php', $content); + } + $content = file_get_contents(__DIR__ . '/../vendor/composer/autoload_psr4.php'); $content = str_replace('$baseDir . \'/daux\'', 'PHAR_DIR . \'/daux\'', $content); $phar->addFromString('vendor/composer/autoload_psr4.php', $content); diff --git a/libs/Format/HTML/ContentTypes/Markdown/TOC/Processor.php b/libs/Format/HTML/ContentTypes/Markdown/TOC/Processor.php index 9618094..bfe6a75 100644 --- a/libs/Format/HTML/ContentTypes/Markdown/TOC/Processor.php +++ b/libs/Format/HTML/ContentTypes/Markdown/TOC/Processor.php @@ -184,21 +184,34 @@ class Processor implements DocumentProcessorInterface return $list; } + protected function setNull($object, $property) { + $prop = new \ReflectionProperty(get_class($object), $property); + $prop->setAccessible(true); + $prop->setValue($object, null); + } + /** * @param Heading $node * @return Node[] */ protected function cloneChildren(Heading $node) { - $deepCopy = new DeepCopy(); - $firstClone = clone $node; - // We have no choice but to hack into the system to reset the parent, to avoid cloning the complete tree - $method = new ReflectionMethod(get_class($firstClone), 'setParent'); - $method->setAccessible(true); - $method->invoke($firstClone, null); + // We have no choice but to hack into the + // system to reset the parent, previous and next + $this->setNull($firstClone, 'parent'); + $this->setNull($firstClone, 'previous'); + $this->setNull($firstClone, 'next'); + // Also, the child elements need to know the next parents + foreach ($firstClone->children() as $subnode) { + $method = new ReflectionMethod(get_class($subnode), 'setParent'); + $method->setAccessible(true); + $method->invoke($subnode, $firstClone); + } + + $deepCopy = new DeepCopy(); return $deepCopy->copy($firstClone)->children(); } }