3 namespace League\HTMLToMarkdown\Converter;
5 use League\HTMLToMarkdown\Configuration;
6 use League\HTMLToMarkdown\ConfigurationAwareInterface;
7 use League\HTMLToMarkdown\ElementInterface;
9 class DefaultConverter implements ConverterInterface, ConfigurationAwareInterface
11 const DEFAULT_CONVERTER = '_default';
19 * @param Configuration $config
21 public function setConfig(Configuration $config)
23 $this->config = $config;
27 * @param ElementInterface $element
31 public function convert(ElementInterface $element)
33 // If strip_tags is false (the default), preserve tags that don't have Markdown equivalents,
34 // such as <span> nodes on their own. C14N() canonicalizes the node to a string.
35 // See: http://www.php.net/manual/en/domnode.c14n.php
36 if ($this->config->getOption('strip_tags', false)) {
37 return $element->getValue();
40 return html_entity_decode($element->getChildrenAsString());
46 public function getSupportedTags()
48 return array(self::DEFAULT_CONVERTER);