Converts the specified element into a parsed string.

@param  \League\HTMLToMarkdown\ElementInterface $element
@return string
182077
public function convert(ElementInterface $element)
    {
        // Contents should have already been converted to Markdown by this point,
        // so we just need to add '>' symbols to each line.

        $markdown = '';

        $quote = trim($element->getValue());

        $lines = preg_split('/\r\n|\r|\n/', $quote);

        $total = count((array) $lines);

        foreach ($lines as $i => $line)
        {
            $markdown .= '> ' . $line . "\n";

            $newline = $i + 1 === $total;

            $newline && $markdown .= "\n";
        }

        return "\n\n" . $markdown;
    }
1280124
public function getInputHtml ($value, ElementInterface $element = null): string
	{
		if ($element !== null && $element->hasEagerLoadedElements($this->handle))
			$value = $element->getEagerLoadedElements($this->handle);

		/** @noinspection PhpComposerExtensionStubsInspection */
		return new Markup(
			$this->_renderMap($value),
			'utf-8'
		);
	}
1047663
protected function formatKeywordElement(KeywordElement $element)
    {
        $name = $element->getName();
        $keyword = $this->getOption(['keywords', $name]);
        $result = call_user_func($keyword, $element->getValue(), $element, $name);

        if (is_string($result)) {
            $result = ['begin' => $result];
        }

        if (!is_array($result) && !($result instanceof \ArrayAccess)) {
            $this->throwException(
                "The keyword $name returned an invalid value type, string or array was expected.",
                $element
            );
        }

        foreach (['begin', 'end'] as $key) {
            $result[$key] = (isset($result[$key.'Php'])
                ? "<?php\n".$result[$key.'Php']."\n?>"
                : ''
            ).(isset($result[$key])
                ? $result[$key]
                : ''
            );
        }

        return implode('', array_filter([
            $result['begin'],
            $this->formatElementChildren($element),
            $result['end'],
        ]));
    }
16856
protected function element(array $Element)
    {
        $markup = '';

        if (str_is('h[1-6]', $Element['name'])) {
            $link = str_replace(' ', '-', strtolower($Element['text']));
            $markup = '<a  class="header-link" href="#'.$link.'" id="'.$link.'"><i class="glyphicon glyphicon-link"></i></a>';
        }

        $markup .= parent::element($Element);

        return $markup;
    }
1106989
public function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
    {
        $url = $this->escapeUrl($this->_urlBuilder->getUrl('dotdigitalgroup_email/run/catalogsync'));

        return $this->getLayout()
            ->createBlock(\Magento\Backend\Block\Widget\Button::class)
            ->setType('button')
            ->setLabel($this->buttonLabel)
            ->setOnClick("window.location.href='" . $url . "'")
            ->toHtml();
    }
753597
public function getInputHtml($value, ElementInterface $element = null): string
    {
        // Get our id and namespace
        $id = Craft::$app->getView()->formatInputId($this->handle);
        $namespacedId = Craft::$app->getView()->namespaceInputId($id);

        // Render the input template
        return Craft::$app->getView()->renderTemplate(
            'preparse-field/_components/fields/_input',
            [
                'name' => $this->handle,
                'value' => $value,
                'field' => $this,
                'id' => $id,
                'namespacedId' => $namespacedId,
            ]
        );
    }
1217948
protected function getPropertyValue(\DOMElement $element, ContextInterface $context)
    {
        $value = $this->getPropertyCache($element);
        if ($value !== null) {
            return $value;
        }

        $propertyChild = $this->getPropertyChildValue($element, $context);
        if ($propertyChild instanceof ThingInterface) {
            return $this->setPropertyCache($element, $propertyChild);
        }

        // Return a string property value
        return $this->setPropertyCache($element, $this->getPropertyStringValue($element));
    }
1345806
public function render(ElementInterface $element): string
    {
        if (! $element instanceof ChoiceElementInterface) {
            throw new InvalidClassException(
                sprintf(
                    'The given element "%s" has to implement "%s"',
                    $element->name(),
                    ChoiceElementInterface::class
                )
            );
        }
        $list = $element->choices();
        $attributes = $element->attributes();
        $choices = $list->choices();
        $selected = $list->choicesForValue((array) $element->value());

        $html = [];

        if (count($choices) < 1) {
            return '';
        }

        $isMultiChoice = false;
        if (count($choices) > 1) {
            $attributes['name'] = $element->name().'[]';
            $isMultiChoice = true;
        }

        foreach ($choices as $key => $name) {
            $elementAttr = $attributes;
            $elementAttr['value'] = $key;
            $elementAttr['checked'] = isset($selected[$key]);
            $elementAttr['id'] = $isMultiChoice
                ? $element->id().'_'.$key
                : $element->id();

            $label = sprintf(
                '<label for="%s">%s</label>',
                $this->escapeAttribute($elementAttr['id']),
                $this->escapeHtml($name)
            );

            $html[] = sprintf(
                '<p><input %s /> %s</p>',
                $this->attributesToString($elementAttr),
                $label
            );
        }

        return implode('', $html);
    }
579878
public function afterElementDelete (ElementInterface $element)
	{
		SimpleMap::getInstance()->map->softDeleteField($this, $element);
		parent::afterElementDelete($element);
	}
854651
protected function renderType(ElementInterface $element)
    {
        $value = $this->getElementValue($element);
        $type  = gettype($value);

        if (isset($this->typeMap[$type])) {
            return $this->renderHelper($this->typeMap[$type], $value, $element);
        }

        return;
    }
47135
public static function parseElement($element)
    {
        if ($element->getName() == "rowset") {
            $re = new RowSet($element);
        } elseif ($element->getName() == "result" && $element->member) { // corp/MemberSecurity workaround
            $container = new Container();
            $container->addElement('members', new PhealRowSet($element, 'members', 'member'));
            $re = new Element('result', $container);
        } else {
            $key = $element->getName();
            $echilds = $element->children();
            if (count($echilds) > 0) {
                $container = new Container();
                foreach ($echilds as $celement) {
                    $cel = Element::parseElement($celement);
                    if (count($celement->attributes()) > 0) {
                        $container->addElement($cel->_name, $cel);
                    } else {
                        $container->addElement($cel->_name, $cel->_value);
                    }
                }
                $value = $container;
            } else {
                $value = (String)$element;
            }

            $re = new Element($key, $value);
            /** @var $element \SimpleXMLElement */
            if (count($element->attributes()) > 0) {
                foreach ($element->attributes() as $name => $attelem) {
                    $re->addAttrib($name, (String)$attelem);
                }
            }

        }
        return $re;
    }
470585
protected static function r_implode($element)
    {
        $string = '';

        if (is_array($element)) {
            reset($element);
            foreach ($element as $value) {
                $string .= ' ' . self::r_implode($value);
            }
        }
        else {
            return $element;
        }

        return '(' . trim($string) . ')';
    }
1069662
public function render(ElementInterface $element)
    {
        $escapeHtmlHelper    = $this->getEscapeHtmlHelper();
        $labelHelper         = $this->getLabelHelper();
        $elementHelper       = $this->getElementHelper();
        $elementErrorsHelper = $this->getElementErrorsHelper();

        $label           = $element->getLabel();
        $inputErrorClass = $this->getInputErrorClass();
        $elementErrors   = $elementErrorsHelper->render($element);

        // Does this element have errors ?
        if (!empty($elementErrors) && !empty($inputErrorClass)) {
            $classAttributes = ($element->hasAttribute('class') ? $element->getAttribute('class') . ' ' : '');
            $classAttributes = $classAttributes . $inputErrorClass;

            $element->setAttribute('class', $classAttributes);
        }

        $elementString = $elementHelper->render($element);

        if (isset($label) && '' !== $label) {
            // Translate the label
            if (null !== ($translator = $this->getTranslator())) {
                $label = $translator->translate(
                    $label,
                    $this->getTranslatorTextDomain()
                );
            }

            $label = $escapeHtmlHelper($label);
            $labelAttributes = $element->getLabelAttributes();

            if (empty($labelAttributes)) {
                $labelAttributes = $this->labelAttributes;
            }

            // Multicheckbox elements have to be handled differently as the HTML standard does not allow nested
            // labels. The semantic way is to group them inside a fieldset
            $type = $element->getAttribute('type');
            if ($type === 'multi_checkbox' || $type === 'radio') {
                $markup = sprintf(
                    '<fieldset><legend>%s</legend>%s</fieldset>',
                    $label,
                    $elementString
                );
            } else {
                if ($element->hasAttribute('id')) {
                    $labelOpen = $labelHelper($element);
                    $labelClose = '';
                    $label = '';
                } else {
                    $labelOpen  = $labelHelper->openTag($labelAttributes);
                    $labelClose = $labelHelper->closeTag();
                }

                if ($label !== '') {
                    $label = '<span>' . $label . '</span>';
                }

                switch ($this->labelPosition) {
                    case self::LABEL_PREPEND:
                        $markup = $labelOpen . $label . $elementString . $labelClose;
                        break;
                    case self::LABEL_APPEND:
                    default:
                        $markup = $labelOpen . $elementString . $label . $labelClose;
                        break;
                }
            }

            if ($this->renderErrors) {
                //$markup .= $elementErrors;
            }
        } else {
            if ($this->renderErrors) {
                $markup = $elementString;  //. $elementErrors;
            } else {
                $markup = $elementString;
            }
        }

        return $markup;
    }
97971
public function render(ElementInterface $element): string
    {
        if (! $element instanceof ErrorAwareInterface) {
            throw new InvalidClassException(
                sprintf(
                    'The given element "%s" does not implement "%s"',
                    $element->name(),
                    ErrorAwareInterface::class
                )
            );
        }

        $errors = $element->errors();
        if (count($errors) < 1) {
            return '';
        }

        $html = array_reduce(
            $errors,
            function ($html, $error): string {
                $html .= sprintf(
                    $this->options['error'],
                    $error
                );

                return $html;
            },
            ''
        );

        return sprintf(
            $this->options['wrapper'],
            $html
        );
    }
853891
public function render(ElementInterface $element): string
    {
        if (! $element instanceof ChoiceElementInterface) {
            throw new InvalidClassException(
                sprintf(
                    'The given element "%s" has to implement "%s"',
                    $element->name(),
                    ChoiceElementInterface::class
                )
            );
        }

        $attributes = $element->attributes();
        unset($attributes['type'], $attributes['value']);

        return sprintf(
            '<select %s>%s</select>',
            $this->attributesToString($attributes),
            $this->renderChoices($element->choices(), $element->value())
        );
    }
177152
protected function getPropertyStringValue(\DOMElement $element)
    {
        // If HTML mode is active
        if ($this->html) {
            $value = $this->getPropertyContentAttrValue($element);
            if ($value === null) {
                $value = $this->getPropertyHtmlValue($element);
            }
            if ($value !== null) {
                return $value;
            }
        }

        // Return the text content
        return $element->textContent;
    }
633610
protected function getIndexKey($element)
    {
        $key = $element->getFullyQualifiedStructuralElementName();

        // properties should have an additional $ before the property name
        if ($element instanceof PropertyInterface) {
            list($fqcn, $propertyName) = explode('::', $key);
            $key = $fqcn . '::$' . $propertyName;
        }

        return $key;
    }