3 namespace League\HTMLToMarkdown\Converter;
5 use League\HTMLToMarkdown\Configuration;
6 use League\HTMLToMarkdown\ConfigurationAwareInterface;
7 use League\HTMLToMarkdown\ElementInterface;
9 class EmphasisConverter implements ConverterInterface, ConfigurationAwareInterface
17 * @param Configuration $config
19 public function setConfig(Configuration $config)
21 $this->config = $config;
25 * @param ElementInterface $element
29 public function convert(ElementInterface $element)
31 $tag = $element->getTagName();
32 $value = $element->getValue();
38 if ($tag === 'i' || $tag === 'em') {
39 $style = $this->config->getOption('italic_style');
41 $style = $this->config->getOption('bold_style');
44 $prefix = ltrim($value) !== $value ? ' ' : '';
45 $suffix = rtrim($value) !== $value ? ' ' : '';
47 return $prefix . $style . trim($value) . $style . $suffix;
53 public function getSupportedTags()
55 return array('em', 'i', 'strong', 'b');