示例#1
0
文件: Section.php 项目: donatj/mddoc
 public function output($depth)
 {
     $title = $this->getOption('title');
     if ($this->getParent() instanceof DocPage) {
         $document = new Document();
     } else {
         $document = new DocumentDepth();
     }
     $document->appendChild(new Header($title));
     foreach ($this->getChildren() as $child) {
         $document->appendChild($child->output($depth + 1));
     }
     return $document;
 }
示例#2
0
 /**
  * @param string $args,...
  * @return \donatj\MDDom\DocumentDepth
  */
 private function descriptionFormat($args)
 {
     $string = implode(PHP_EOL, func_get_args());
     $parts = explode(PHP_EOL, $string);
     $document = new DocumentDepth();
     $runningText = "";
     while (($part = current($parts)) !== false) {
         $part = rtrim($part);
         $next = next($parts);
         $lastPart = strrev($part);
         if ($lastPart) {
             $lastPart = $lastPart[0];
         }
         if ($lastPart == ':') {
             if (trim($runningText)) {
                 $document->appendChild(new MdText($this->smartLineTrim($runningText)));
                 $runningText = "";
             }
             $document->appendChild(new Header(substr($part, 0, -1)));
         } else {
             $runningText .= "  \n" . $part;
             // @todo this is gross... fix this.
         }
     }
     if (trim($runningText)) {
         $document->appendChild(new MdText($this->smartLineTrim($runningText)));
     }
     return $document;
 }