public function closeUnmatchedBlocks() { while ($this->oldTip !== $this->lastMatchedContainer) { $this->oldTip->finalize($this->context); $this->oldTip = $this->oldTip->getParent(); } }
public function closeUnmatchedBlocks() { while ($this->oldTip !== $this->lastMatchedContainer) { $oldTip = $this->oldTip->parent(); $this->oldTip->finalize($this->context, $this->context->getLineNumber() - 1); $this->oldTip = $oldTip; } }
/** * @param AbstractBlock $block * * @return AbstractBlock */ public function addBlock(AbstractBlock $block) { $this->getBlockCloser()->closeUnmatchedBlocks(); $block->setStartLine($this->lineNumber); while (!$this->tip->canContain($block)) { $this->tip->finalize($this); } $this->tip->addChild($block); $this->tip = $block; $this->container = $block; return $block; }
public function finalize(ContextInterface $context, $endLineNumber) { parent::finalize($context, $endLineNumber); $this->finalStringContents = preg_replace('/^ */m', '', implode("\n", $this->getStrings())); // Short-circuit if ($this->finalStringContents === '' || $this->finalStringContents[0] !== '[') { return; } $cursor = new Cursor($this->finalStringContents); $referenceFound = $this->parseReferences($context, $cursor); $this->finalStringContents = $cursor->getRemainder(); if ($referenceFound && $cursor->isAtEnd()) { $this->detach(); } }
public function finalize(ContextInterface $context) { parent::finalize($context); $reversed = array_reverse($this->getStrings(), true); foreach ($reversed as $index => $line) { if ($line == '' || $line === "\n" || preg_match('/^(\\n *)$/', $line)) { unset($reversed[$index]); } else { break; } } $fixed = array_reverse($reversed); $tmp = implode("\n", $fixed); if (substr($tmp, -1) !== "\n") { $tmp .= "\n"; } $this->finalStringContents = $tmp; }
public function finalize(ContextInterface $context) { parent::finalize($context); // first line becomes info string $this->info = RegexHelper::unescape(trim($this->strings->first())); if ($this->strings->count() == 1) { $this->finalStringContents = ''; } else { $this->finalStringContents = implode("\n", $this->strings->slice(1)) . "\n"; } }
public function finalize(ContextInterface $context, $endLineNumber) { parent::finalize($context, $endLineNumber); $this->finalStringContents = implode("\n", $this->getStrings()); }
public function finalize(ContextInterface $context) { parent::finalize($context); $this->tight = true; // tight by default foreach ($this->children as $item) { // check for non-final list item ending with blank line: if ($item->endsWithBlankLine() && $item !== $this->getLastChild()) { $this->tight = false; break; } // Recurse into children of list item, to see if there are // spaces between any of them: foreach ($item->getChildren() as $subItem) { if ($subItem->endsWithBlankLine() && ($item !== $this->getLastChild() || $subItem !== $item->getLastChild())) { $this->tight = false; break; } } } }
/** * Break out of all containing lists, resetting the tip of the * document to the parent of the highest list, and finalizing * all the lists. (This is used to implement the "two blank lines * break of of all lists" feature.) * * @param ContextInterface $context * @param AbstractBlock $block */ private function breakOutOfLists(ContextInterface $context, AbstractBlock $block) { $b = $block; $lastList = null; do { if ($b instanceof ListBlock) { $lastList = $b; } $b = $b->getParent(); } while ($b); if ($lastList) { while ($block !== $lastList) { $block->finalize($context); $block = $block->getParent(); } $lastList->finalize($context); } }