/** * @param Node $node */ protected function setParent(Node $node) { if ($node && !$node instanceof self) { throw new \InvalidArgumentException('Parent of block must also be block (can not be inline)'); } parent::setParent($node); }
/** * @param string $character * @param Node $container * @param InlineParserContext $inlineParserContext */ private function addPlainText($character, Node $container, InlineParserContext $inlineParserContext) { // We reach here if none of the parsers can handle the input // Attempt to match multiple non-special characters at once $text = $inlineParserContext->getCursor()->match($this->environment->getInlineParserCharacterRegex()); // This might fail if we're currently at a special character which wasn't parsed; if so, just add that character if ($text === null) { $inlineParserContext->getCursor()->advance(); $text = $character; } $lastInline = $container->lastChild(); if ($lastInline instanceof Text && !isset($lastInline->data['delim'])) { $lastInline->append($text); } else { $container->appendChild(new Text($text)); } }
/** * @param Node $child */ public function prependChild(Node $child) { if ($this->firstChild) { $this->firstChild->insertBefore($child); } else { $child->detach(); $child->setParent($this); $this->lastChild = $this->firstChild = $child; } }
private function getNext(Node $node = null) { if ($node instanceof Node) { return $node instanceof AbstractBlock && $node->endsWithBlankLine() ? null : $node->next(); } }