当前位置: 首页>>代码示例>>PHP>>正文


PHP Cursor::getFirstNonSpacePosition方法代码示例

本文整理汇总了PHP中League\CommonMark\Cursor::getFirstNonSpacePosition方法的典型用法代码示例。如果您正苦于以下问题:PHP Cursor::getFirstNonSpacePosition方法的具体用法?PHP Cursor::getFirstNonSpacePosition怎么用?PHP Cursor::getFirstNonSpacePosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在League\CommonMark\Cursor的用法示例。


在下文中一共展示了Cursor::getFirstNonSpacePosition方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse

 /**
  * @param ContextInterface $context
  * @param Cursor $cursor
  *
  * @return bool
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     $match = RegexHelper::matchAt(RegexHelper::getInstance()->getHtmlBlockOpenRegex(), $cursor->getLine(), $cursor->getFirstNonSpacePosition());
     if ($match === null) {
         return false;
     }
     $context->addBlock(new HtmlBlock());
     $context->setBlocksParsed(true);
     return true;
 }
开发者ID:alvarobfdev,项目名称:LaravelCore,代码行数:16,代码来源:HtmlBlockParser.php

示例2: parse

 /**
  * @param ContextInterface $context
  * @param Cursor $cursor
  *
  * @return bool
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     if ($cursor->getFirstNonSpaceCharacter() !== 'A' || $cursor->getCharacter($cursor->getFirstNonSpacePosition() + 1) !== '>') {
         return false;
     }
     $cursor->advanceToFirstNonSpace();
     if ($cursor->peek() === '>') {
         $cursor->advanceBy(2);
         if ($cursor->getCharacter() === ' ') {
             $cursor->advance();
         }
     }
     $context->addBlock(new Aside());
     return true;
 }
开发者ID:austinvernsonger,项目名称:markua,代码行数:21,代码来源:AsideParser.php

示例3: parse

 /**
  * @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;
 }
开发者ID:LyricFinancial,项目名称:integration-guides,代码行数:21,代码来源:ThematicBreakParser.php

示例4: parse

 /**
  * @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;
 }
开发者ID:alvarobfdev,项目名称:LaravelCore,代码行数:22,代码来源:ATXHeaderParser.php

示例5: parse

 /**
  * @param ContextInterface $context
  * @param Cursor $cursor
  *
  * @return bool
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     if (!in_array($cursor->getFirstNonSpaceCharacter(), IconBlock::getIconBlockTypes()) || $cursor->getCharacter($cursor->getFirstNonSpacePosition() + 1) !== '>') {
         return false;
     }
     $type = $cursor->getFirstNonSpaceCharacter();
     $cursor->advanceToFirstNonSpace();
     if ($cursor->peek() === '>') {
         $cursor->advanceBy(2);
         if ($cursor->getCharacter() === ' ') {
             $cursor->advance();
         }
     }
     $context->addBlock(new IconBlock($type));
     return true;
 }
开发者ID:austinvernsonger,项目名称:markua,代码行数:22,代码来源:IconBlockParser.php

示例6: parse

 public function parse(ContextInterface $context, Cursor $cursor)
 {
     $container = $context->getContainer();
     if (!$container instanceof Paragraph) {
         return false;
     }
     $lines = $container->getStrings();
     if (count($lines) < 1) {
         return false;
     }
     $match = RegexHelper::matchAll(self::REGEXP_DEFINITION, $cursor->getLine(), $cursor->getFirstNonSpacePosition());
     if (null === $match) {
         return false;
     }
     $columns = $this->parseColumns($match);
     $head = $this->parseRow(trim(array_pop($lines)), $columns, TableCell::TYPE_HEAD);
     if (null === $head) {
         return false;
     }
     $table = new Table(function (Cursor $cursor) use(&$table, $columns) {
         $row = $this->parseRow($cursor->getLine(), $columns);
         if (null === $row) {
             if (null !== $table->getCaption()) {
                 return false;
             }
             if (null !== ($caption = $this->parseCaption($cursor->getLine()))) {
                 $table->setCaption($caption);
                 return true;
             }
             return false;
         }
         $table->getBody()->appendChild($row);
         return true;
     });
     $table->getHead()->appendChild($head);
     if (count($lines) >= 1) {
         $paragraph = new Paragraph();
         foreach ($lines as $line) {
             $paragraph->addLine($line);
         }
         $context->replaceContainerBlock($paragraph);
         $context->addBlock($table);
     } else {
         $context->replaceContainerBlock($table);
     }
     return true;
 }
开发者ID:webuni,项目名称:commonmark-table-extension,代码行数:47,代码来源:TableParser.php

示例7: parse

 /**
  * @param ContextInterface $context
  * @param Cursor           $cursor
  *
  * @return bool
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     if ($cursor->isIndented()) {
         return false;
     }
     if (!$context->getContainer() instanceof Paragraph) {
         return false;
     }
     $match = RegexHelper::matchAll('/^(?:=+|-+)[ \\t]*$/', $cursor->getLine(), $cursor->getFirstNonSpacePosition());
     if ($match === null) {
         return false;
     }
     $level = $match[0][0] === '=' ? 1 : 2;
     $strings = $context->getContainer()->getStrings();
     $context->replaceContainerBlock(new Heading($level, $strings));
     return true;
 }
开发者ID:colinodell,项目名称:commonmark-php,代码行数:23,代码来源:SetExtHeadingParser.php

示例8: handleRemainingContents

 /**
  * @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());
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:20,代码来源:FencedCode.php


注:本文中的League\CommonMark\Cursor::getFirstNonSpacePosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。