當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Listing::last方法代碼示例

本文整理匯總了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;
 }
開發者ID:xp-forge,項目名稱:markdown,代碼行數:55,代碼來源:ListContext.class.php


注:本文中的Listing::last方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。