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


PHP Cursor::getIndent方法代码示例

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


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

示例1: parse

 /**
  * @param ContextInterface $context
  * @param Cursor $cursor
  *
  * @return bool
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     if ($cursor->getIndent() < IndentedCodeParser::CODE_INDENT_LEVEL) {
         return false;
     }
     $context->setBlocksParsed(true);
     return true;
 }
开发者ID:alvarobfdev,项目名称:LaravelCore,代码行数:14,代码来源:LazyParagraphParser.php

示例2: matchesNextLine

 public function matchesNextLine(Cursor $cursor)
 {
     if ($cursor->getIndent() >= $this->listData->markerOffset + $this->listData->padding) {
         $cursor->advanceBy($this->listData->markerOffset + $this->listData->padding, true);
     } elseif ($cursor->isBlank()) {
         $cursor->advanceToFirstNonSpace();
     } else {
         return false;
     }
     return true;
 }
开发者ID:ssomenzi,项目名称:silence,代码行数:11,代码来源:ListItem.php

示例3: matchesNextLine

 public function matchesNextLine(Cursor $cursor)
 {
     if ($cursor->getIndent() >= IndentedCodeParser::CODE_INDENT_LEVEL) {
         $cursor->advanceBy(IndentedCodeParser::CODE_INDENT_LEVEL);
     } elseif ($cursor->isBlank()) {
         $cursor->advanceToFirstNonSpace();
     } else {
         return false;
     }
     return true;
 }
开发者ID:alvarobfdev,项目名称:LaravelCore,代码行数:11,代码来源:IndentedCode.php

示例4: matchesNextLine

 public function matchesNextLine(Cursor $cursor)
 {
     if ($cursor->getIndent() <= 3 && $cursor->getFirstNonSpaceCharacter() === '>') {
         $cursor->advanceToFirstNonSpace();
         $cursor->advance();
         if ($cursor->getCharacter() === ' ') {
             $cursor->advance();
         }
         return true;
     }
     return false;
 }
开发者ID:alvarobfdev,项目名称:LaravelCore,代码行数:12,代码来源:BlockQuote.php

示例5: matchesNextLine

 public function matchesNextLine(Cursor $cursor)
 {
     if ($cursor->getIndent() <= 3 && in_array($cursor->getFirstNonSpaceCharacter(), static::getIconBlockTypes())) {
         $cursor->advanceToFirstNonSpace();
         if ($cursor->peek() === '>') {
             $cursor->advanceBy(2);
             if ($cursor->getCharacter() === ' ') {
                 $cursor->advance();
             }
             return true;
         }
     }
     return false;
 }
开发者ID:austinvernsonger,项目名称:markua,代码行数:14,代码来源:IconBlock.php

示例6: parse

 /**
  * @param ContextInterface $context
  * @param Cursor $cursor
  *
  * @return bool
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     if ($cursor->getIndent() < self::CODE_INDENT_LEVEL) {
         return false;
     }
     if ($context->getTip() instanceof Paragraph) {
         return false;
     }
     if ($cursor->isBlank()) {
         return false;
     }
     $cursor->advanceBy(self::CODE_INDENT_LEVEL);
     $context->addBlock(new IndentedCode());
     return true;
 }
开发者ID:alvarobfdev,项目名称:LaravelCore,代码行数:21,代码来源:IndentedCodeParser.php

示例7: parse

 /**
  * @param ContextInterface $context
  * @param Cursor           $cursor
  *
  * @return bool
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     if ($cursor->isIndented() && !$context->getContainer() instanceof ListBlock) {
         return false;
     }
     $tmpCursor = clone $cursor;
     $tmpCursor->advanceToFirstNonSpace();
     $rest = $tmpCursor->getRemainder();
     $data = new ListData();
     $data->markerOffset = $cursor->getIndent();
     if ($matches = RegexHelper::matchAll('/^[*+-]/', $rest)) {
         $data->type = ListBlock::TYPE_UNORDERED;
         $data->delimiter = null;
         $data->bulletChar = $matches[0][0];
     } elseif (($matches = RegexHelper::matchAll('/^(\\d{1,9})([.)])/', $rest)) && (!$context->getContainer() instanceof Paragraph || $matches[1] === '1')) {
         $data->type = ListBlock::TYPE_ORDERED;
         $data->start = intval($matches[1]);
         $data->delimiter = $matches[2];
         $data->bulletChar = null;
     } else {
         return false;
     }
     $markerLength = strlen($matches[0]);
     // Make sure we have spaces after
     $nextChar = $tmpCursor->peek($markerLength);
     if (!($nextChar === null || $nextChar === "\t" || $nextChar === ' ')) {
         return false;
     }
     // If it interrupts paragraph, make sure first line isn't blank
     if ($context->getContainer() instanceof Paragraph && !RegexHelper::matchAt(RegexHelper::REGEX_NON_SPACE, $rest, $markerLength)) {
         return false;
     }
     // We've got a match! Advance offset and calculate padding
     $cursor->advanceToFirstNonSpace();
     // to start of marker
     $cursor->advanceBy($markerLength, true);
     // to end of marker
     $data->padding = $this->calculateListMarkerPadding($cursor, $markerLength);
     // add the list if needed
     $container = $context->getContainer();
     if (!$container || !$context->getContainer() instanceof ListBlock || !$data->equals($container->getListData())) {
         $context->addBlock(new ListBlock($data));
     }
     // add the list item
     $context->addBlock(new ListItem($data));
     return true;
 }
开发者ID:colinodell,项目名称:commonmark-php,代码行数:53,代码来源:ListParser.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::getIndent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。