本文整理汇总了PHP中League\CommonMark\Cursor::getRemainder方法的典型用法代码示例。如果您正苦于以下问题:PHP Cursor::getRemainder方法的具体用法?PHP Cursor::getRemainder怎么用?PHP Cursor::getRemainder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\CommonMark\Cursor
的用法示例。
在下文中一共展示了Cursor::getRemainder方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRemainingContents
/**
* @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());
}
示例2: 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;
}
示例3: 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;
}
示例4: parse
/**
* @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;
}
示例5: handleRemainingContents
/**
* @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());
}
示例6: handleRemainingContents
/**
* @param ContextInterface $context
* @param Cursor $cursor
*/
public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
{
$cursor->advanceToFirstNonSpace();
$context->getTip()->addLine($cursor->getRemainder());
}
示例7: 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());
}
示例8: handleRemainingContents
/**
* @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());
}
}
}