setTip() public method

public setTip ( AbstractBlock $block )
$block League\CommonMark\Block\Element\AbstractBlock
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     $document = $context->getDocument();
     $tip = $context->getTip();
     if (!$document->getLastChild() instanceof AttributesDocument) {
         $attributesDocument = new AttributesDocument();
         foreach ($document->getChildren() as $child) {
             $document->removeChild($child);
             $attributesDocument->addChild($child);
         }
         $document->addChild($attributesDocument);
         if ($tip instanceof Document) {
             $context->setTip($attributesDocument);
         }
     }
     $state = $cursor->saveState();
     $attributes = AttributesUtils::parse($cursor);
     if (empty($attributes)) {
         return false;
     }
     if (null !== $cursor->getFirstNonSpaceCharacter()) {
         $cursor->restoreState($state);
         return false;
     }
     $prepend = $tip instanceof Document || !$tip->getParent() instanceof Document && $context->getBlockCloser()->areAllClosed();
     $context->addBlock(new Attributes($attributes, $prepend ? Attributes::PREPEND : Attributes::APPEND));
     $context->setBlocksParsed(true);
     return true;
 }
Beispiel #2
0
 /**
  * Finalize the block; mark it closed for modification
  *
  * @param ContextInterface $context
  * @param int              $endLineNumber
  */
 public function finalize(ContextInterface $context, $endLineNumber)
 {
     if (!$this->open) {
         return;
         // TODO: Throw AlreadyClosedException?
     }
     $this->open = false;
     $this->endLine = $endLineNumber;
     $context->setTip($context->getTip()->parent());
 }
 /**
  * Finalize the block; mark it closed for modification
  *
  * @param ContextInterface $context
  */
 public function finalize(ContextInterface $context)
 {
     if (!$this->open) {
         return;
         // TODO: Throw AlreadyClosedException?
     }
     $this->open = false;
     if ($context->getLineNumber() > $this->getStartLine()) {
         $this->endLine = $context->getLineNumber() - 1;
     } else {
         $this->endLine = $context->getLineNumber();
     }
     $context->setTip($context->getTip()->getParent());
 }