protected function handleTagToText() { if (!$this->keepHTML) { if (!$this->parser->isStartTag && $this->parser->isBlockElement) { $this->setLineBreaks(2); } } else { // dont convert to markdown inside this tag /** TODO: markdown extra **/ if (!$this->parser->isEmptyTag) { if ($this->parser->isStartTag) { if (!$this->skipConversion) { $this->skipConversion = $this->parser->tagName . '::' . implode('/', $this->parser->openTags); } } else { if ($this->skipConversion == $this->parser->tagName . '::' . implode('/', $this->parser->openTags)) { $this->skipConversion = false; } } } if ($this->parser->isBlockElement) { if ($this->parser->isStartTag) { // looks like ins or del are block elements now if (in_array($this->parent(), array('ins', 'del'))) { $this->out("\n", true); $this->indent(' '); } // don't indent inside <pre> tags if ($this->parser->tagName == 'pre') { $this->out($this->parser->node); static $indent; $indent = $this->indent; $this->indent = ''; } else { $this->out($this->parser->node . "\n" . $this->indent); if (!$this->parser->isEmptyTag) { $this->indent(' '); } else { $this->setLineBreaks(1); } $this->parser->html = ltrim($this->parser->html); } } else { if (!$this->parser->keepWhitespace) { $this->output = rtrim($this->output); } if ($this->parser->tagName != 'pre') { $this->indent(' '); $this->out("\n" . $this->indent . $this->parser->node); } else { // reset indentation $this->out($this->parser->node); static $indent; $this->indent = $indent; } if (in_array($this->parent(), array('ins', 'del'))) { // ins or del was block element $this->out("\n"); $this->indent(' '); } if ($this->parser->tagName == 'li') { $this->setLineBreaks(1); } else { $this->setLineBreaks(2); } } } else { $this->out($this->parser->node); } if (in_array($this->parser->tagName, array('code', 'pre'))) { if ($this->parser->isStartTag) { $this->buffer(); } else { // add stuff so cleanup just reverses this $this->out(str_replace('<', '&lt;', str_replace('>', '&gt;', $this->unbuffer()))); } } } }