Example #1
0
 /**
  * @param ElementInterface $element
  *
  * @return string
  */
 public function convert(ElementInterface $element)
 {
     if ($this->config->getOption('strip_tags', false)) {
         return $element->getValue() . PHP_EOL . PHP_EOL;
     }
     return html_entity_decode($element->getChildrenAsString());
 }
 /**
  * @param ElementInterface $element
  *
  * @return string
  */
 public function convert(ElementInterface $element)
 {
     // If strip_tags is false (the default), preserve tags that don't have Markdown equivalents,
     // such as <span> nodes on their own. C14N() canonicalizes the node to a string.
     // See: http://www.php.net/manual/en/domnode.c14n.php
     if ($this->config->getOption('strip_tags', false)) {
         return $element->getValue();
     }
     return html_entity_decode($element->getChildrenAsString());
 }
 /**
  * @param ElementInterface $element
  *
  * @return string
  */
 public function convert(ElementInterface $element)
 {
     $level = (int) substr($element->getTagName(), 1, 1);
     $style = $this->config->getOption('header_style', self::STYLE_SETEXT);
     if (($level === 1 || $level === 2) && !$element->isDescendantOf('blockquote') && $style === self::STYLE_SETEXT) {
         return $this->createSetextHeader($level, $element->getValue());
     } else {
         return $this->createAtxHeader($level, $element->getValue());
     }
 }
 /**
  * @param ElementInterface $element
  *
  * @return string
  */
 public function convert(ElementInterface $element)
 {
     $tag = $element->getTagName();
     $value = $element->getValue();
     if ($tag === 'i' || $tag === 'em') {
         $style = $this->config->getOption('italic_style');
     } else {
         $style = $this->config->getOption('bold_style');
     }
     return $style . $value . $style;
 }
Example #5
0
 /**
  * @param ElementInterface $element
  *
  * @return string
  */
 public function convert(ElementInterface $element)
 {
     $tag = $element->getTagName();
     $value = $element->getValue();
     if ($tag === 'i' || $tag === 'em') {
         $style = $this->config->getOption('italic_style');
     } else {
         $style = $this->config->getOption('bold_style');
     }
     $prefix = ltrim($value) !== $value ? ' ' : '';
     $suffix = rtrim($value) !== $value ? ' ' : '';
     return $prefix . $style . trim($value) . $style . $suffix;
 }