本文整理汇总了PHP中Listing::last方法的典型用法代码示例。如果您正苦于以下问题:PHP Listing::last方法的具体用法?PHP Listing::last怎么用?PHP Listing::last使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Listing
的用法示例。
在下文中一共展示了Listing::last方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* Parse input into nodes
*
* @param net.daringfireball.markdown.Input $lines
* @return net.daringfireball.markdown.Node
*/
public function parse($lines)
{
$empty = false;
$target = null;
$result = new Listing($this->type);
while ($lines->hasMoreLines()) {
$line = $lines->nextLine();
// An empty line makes the list use paragraphs, except if it's the last line.
if (0 === $line->length()) {
$empty = true;
continue;
}
// Indented elements form additional paragpraphs inside list items. If
// the line doesn't start with a list bullet, this means the list is at
// its end.
if (preg_match('/^(\\s+)?([+*-]+|[0-9]+\\.) /', $line, $m) && !preg_match('/^(\\* ?){3,}$/', $line)) {
$empty && ($result->paragraphs = true);
$empty = false;
// Check whether we need to indent / dedent the list level, or whether
// the list item belongs to this list
$level = strlen($m[1]) / 2;
if ($level > $this->level) {
$lines->resetLine($line);
$target = $target ?: $result->add(new ListItem($result))->add(new Paragraph());
$target->add($this->enter(new self($this->type, $level))->parse($lines));
} else {
if ($level < $this->level) {
$lines->resetLine($line);
break;
} else {
$target = $result->add(new ListItem($result))->add(new Paragraph());
$line->forward(strlen($m[0]));
$this->tokenize($line, $target);
}
}
} else {
if (' ' === substr($line, 0, 2)) {
// Add paragraph to existing list item
$paragraph = $result->last()->add(new Paragraph());
$line->forward(2);
$this->tokenize($line, $paragraph);
} else {
$lines->resetLine($line);
break;
}
}
}
return $result;
}