/** * renderInline * * @param CommonMark_Element_InlineElementInterface $inline * @access public * @return void */ public function renderInline(CommonMark_Element_InlineElementInterface $inline) { if ($inline->getType() == CommonMark_Element_InlineElement::TYPE_SOFTBREAK) { $inline->setType(CommonMark_Element_InlineElement::TYPE_HARDBREAK); } return parent::renderInline($inline); }
/** * @param InlineElementInterface $inline * * @return mixed|string * * @throws \InvalidArgumentException */ public function renderInline(CommonMark_Element_InlineElementInterface $inline) { $attrs = array(); switch ($inline->getType()) { case CommonMark_Element_InlineElement::TYPE_STRING: return $this->escape($inline->getContents()); case CommonMark_Element_InlineElement::TYPE_SOFTBREAK: return $this->softBreak; case CommonMark_Element_InlineElement::TYPE_HARDBREAK: return $this->inTags('br', array(), '', true) . "\n"; case CommonMark_Element_InlineElement::TYPE_EMPH: return $this->inTags('em', array(), $this->renderInlines($inline->getContents())); case CommonMark_Element_InlineElement::TYPE_STRONG: return $this->inTags('strong', array(), $this->renderInlines($inline->getContents())); case CommonMark_Element_InlineElement::TYPE_HTML: return $inline->getContents(); case CommonMark_Element_InlineElement::TYPE_ENTITY: return $inline->getContents(); case CommonMark_Element_InlineElement::TYPE_LINK: $attrs['href'] = $this->escape($inline->getAttribute('destination'), true); if ($title = $inline->getAttribute('title')) { $attrs['title'] = $this->escape($title, true); } return $this->inTags('a', $attrs, $this->renderInlines($inline->getAttribute('label'))); case CommonMark_Element_InlineElement::TYPE_IMAGE: $attrs['src'] = $this->escape($inline->getAttribute('destination'), true); $attrs['alt'] = $this->escape($this->renderInlines($inline->getAttribute('label'))); if ($title = $inline->getAttribute('title')) { $attrs['title'] = $this->escape($title, true); } return $this->inTags('img', $attrs, '', true); case CommonMark_Element_InlineElement::TYPE_CODE: return $this->inTags('code', array(), $this->escape($inline->getContents())); default: throw new InvalidArgumentException('Unknown inline type: ' . $inline->getType()); } }