public function render()
 {
     #print __CLASS__.'->'.__FUNCTION__.': "'.$this->getName().'"'."\n";
     if ($this->getContent()) {
         #print __CLASS__.'->'.__FUNCTION__.':     render'."\n";
         return parent::render();
     }
     return '';
 }
Example #2
0
 /**
  * The main parsing function. Returns a parsed document AST.
  * @param string $input
  *
  * @return BlockElement
  *
  * @api
  */
 public function parse($input)
 {
     $this->doc = new CommonMark_Element_BlockElement(CommonMark_Element_BlockElement::TYPE_DOCUMENT, 1, 1);
     $this->tip = $this->doc;
     $this->inlineParser = new CommonMark_InlineParser();
     $this->refMap = new CommonMark_Reference_ReferenceMap();
     // Remove any /n which appears at the very end of the string
     if (substr($input, -1) == "\n") {
         $input = substr($input, 0, -1);
     }
     $lines = preg_split('/\\r\\n|\\n|\\r/', $input);
     $len = count($lines);
     for ($i = 0; $i < $len; $i++) {
         $this->incorporateLine($lines[$i], $i + 1);
     }
     while ($this->tip) {
         $this->finalize($this->tip, $len - 1);
     }
     $this->doc->processInlines($this->inlineParser, $this->refMap);
     return $this->doc;
 }