getRemainder() public method

public getRemainder ( ) : string
return string
Beispiel #1
0
 /**
  * @param ContextInterface $context
  * @param Cursor           $cursor
  */
 public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
 {
     if ($cursor->isBlank()) {
         return;
     }
     $context->addBlock(new Paragraph());
     $cursor->advanceToFirstNonSpace();
     $context->getTip()->addLine($cursor->getRemainder());
 }
 /**
  * @param ContextInterface $context
  * @param Cursor           $cursor
  *
  * @return bool
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     if ($cursor->isIndented()) {
         return false;
     }
     $match = RegexHelper::matchAt(RegexHelper::getInstance()->getThematicBreakRegex(), $cursor->getLine(), $cursor->getFirstNonSpacePosition());
     if ($match === null) {
         return false;
     }
     // Advance to the end of the string, consuming the entire line (of the thematic break)
     $cursor->advanceBy(mb_strlen($cursor->getRemainder()));
     $context->addBlock(new ThematicBreak());
     $context->setBlocksParsed(true);
     return true;
 }
 /**
  * @param ContextInterface $context
  * @param Cursor $cursor
  *
  * @return bool
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     $match = RegexHelper::matchAll('/^#{1,6}(?: +|$)/', $cursor->getLine(), $cursor->getFirstNonSpacePosition());
     if (!$match) {
         return false;
     }
     $cursor->advanceToFirstNonSpace();
     $cursor->advanceBy(strlen($match[0]));
     $level = strlen(trim($match[0]));
     $str = $cursor->getRemainder();
     $str = preg_replace('/^ *#+ *$/', '', $str);
     $str = preg_replace('/ +#+ *$/', '', $str);
     $context->addBlock(new Header($level, $str));
     $context->setBlocksParsed(true);
     return true;
 }
 /**
  * @param ContextInterface $context
  * @param Cursor           $cursor
  *
  * @return bool
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     if ($cursor->isIndented()) {
         return false;
     }
     if ($cursor->getFirstNonSpaceCharacter() !== '<') {
         return false;
     }
     $savedState = $cursor->saveState();
     $cursor->advanceToFirstNonSpace();
     $line = $cursor->getRemainder();
     for ($blockType = 1; $blockType <= 7; $blockType++) {
         $match = RegexHelper::matchAt(RegexHelper::getHtmlBlockOpenRegex($blockType), $line);
         if ($match !== null && ($blockType < 7 || !$context->getContainer() instanceof Paragraph)) {
             $cursor->restoreState($savedState);
             $context->addBlock(new HtmlBlock($blockType));
             $context->setBlocksParsed(true);
             return true;
         }
     }
     $cursor->restoreState($savedState);
     return false;
 }
Beispiel #5
0
 /**
  * @param ContextInterface $context
  * @param Cursor           $cursor
  */
 public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
 {
     // create paragraph container for line
     $context->addBlock(new Paragraph());
     $cursor->advanceToFirstNonSpace();
     $context->getTip()->addLine($cursor->getRemainder());
 }
 /**
  * @param ContextInterface $context
  * @param Cursor           $cursor
  */
 public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
 {
     $cursor->advanceToFirstNonSpace();
     $context->getTip()->addLine($cursor->getRemainder());
 }
Beispiel #7
0
 /**
  * @param ContextInterface $context
  * @param Cursor           $cursor
  */
 public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
 {
     /** @var FencedCode $container */
     $container = $context->getContainer();
     // check for closing code fence
     if ($cursor->getIndent() <= 3 && $cursor->getFirstNonSpaceCharacter() == $container->getChar()) {
         $match = RegexHelper::matchAll('/^(?:`{3,}|~{3,})(?= *$)/', $cursor->getLine(), $cursor->getFirstNonSpacePosition());
         if (strlen($match[0]) >= $container->getLength()) {
             // don't add closing fence to container; instead, close it:
             $this->setLength(-1);
             // -1 means we've passed closer
             return;
         }
     }
     $context->getTip()->addLine($cursor->getRemainder());
 }
 /**
  * @param ContextInterface $context
  * @param Cursor           $cursor
  */
 public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
 {
     $context->getTip()->addLine($cursor->getRemainder());
     // Check for end condition
     if ($this->type >= self::TYPE_1_CODE_CONTAINER && $this->type <= self::TYPE_5_CDATA) {
         if ($cursor->match(RegexHelper::getHtmlBlockCloseRegex($this->type)) !== null) {
             $this->finalize($context, $context->getLineNumber());
         }
     }
 }