Replaces the example tags in the description with the contents of the found example.

@param DescriptorAbstract $element

@return string
186933
protected function replaceInlineExamples(DescriptorAbstract $element)
    {
        $description = $element->getDescription();
        $matches     = array();

        if (! $description
            || ! preg_match_all('/\{@example\s(.+?)\}/', $description, $matches)
            || count($matches[0]) < 1
        ) {
            return $description;
        }

        $matched = array();
        foreach ($matches[0] as $index => $match) {
            if (isset($matched[$match])) {
                continue;
            }

            $matched[$match] = true;
            $exampleReflector = new ExampleTag('example', $matches[1][$index]);

            $example = $this->exampleAssembler->create($exampleReflector);

            $replacement = '`'.$example->getExample().'`';
            if ($example->getDescription()) {
                $replacement = '*' . $example->getDescription() . '*' . $replacement;
            }

            $description = str_replace($match, $replacement, $description);
        }

        return $description;
    }
173474
public static function sources(Element $element)
    {
        $html = '';
        foreach ($element->html() as $attributes) {
            $attributes['srcset'] = is_callable($attributes['srcset'])
                ? $attributes['srcset']($element->image()['src'] ?? '')
                : ($element->image()['src'] ?? '');
            $html                 .= Render::tag('source', $attributes, null, Render::FILTER_NULL);
        }

        $html .= Render::tag('img', $element->image(), null, Render::FILTER_NULL);

        return $html;
    }
429878
public function renderElement(Element $element) : string
    {
        // @todo - if the element implements neither HasContent or HasChildren, make it self-closing <img />
        // @todo - fix indentation - currently it adds an extra line as the middle indentation
        return $this->indent($this->depth, sprintf('<%s%s>', $element->getElement(), $this->getAttributesForElement($element))) .
            $this->indent($this->depth++, $this->getContentForElement($element)) .
            $this->indent(--$this->depth, sprintf('</%s>', $element->getElement()));
    }
1256482
protected function addSummary(\DOMElement $node, DescriptorAbstract $element)
    {
        $node->appendChild(new \DOMElement('description'))
            ->appendChild(new \DOMText($element->getSummary()));
    }
1165656
protected function _getElementHtml(AbstractElement $element) {
        $callbackUrl= $this->getBaseUrl() . 'checkout_com/' . $this->getControllerUrl();

        $element->setData('value', $callbackUrl);
        $element->setReadonly('readonly');

        return $element->getElementHtml();
    }
1143397
private function replaceTagsWithText(Element $topNode): self {
        if (!empty($topNode)) {
            $items = $topNode->find('b, strong, i');

            foreach ($items as $item) {
                $item->replaceWith(new Text($this->getTagCleanedText($item)));
            }
            
            $headers = $topNode->find('h1, h2, h3, h4, h5, h6');

            foreach ($headers as $header) {
                $header->replaceWith(new Text("\n\n" . $this->getTagCleanedText($header) . "\n\n"));
            }
        }

        return $this;
    }
434754
public static function extract(\DOMElement $element)
    {
        $doc = new \DOMDocument('1.0', 'utf-8');
        $imported = $doc->importNode($element, true);
        $doc->appendChild($imported);

        $prefix = $doc->lookupPrefix('http://www.w3.org/1999/xhtml');
        if ('' !== $prefix) {
            $prefix .= ':';
        }
        $patterns = [
            '/<\?xml[^<]*>[^<]*<' . $prefix . 'div[^<]*/',
            '/<\/' . $prefix . 'div>\s*$/'
        ];
        $text = preg_replace($patterns, '', $doc->saveXML());
        if ('' !== $prefix) {
            $text = preg_replace('/(<[\/]?)' . $prefix . '([a-zA-Z]+)/', '$1$2', $text);
        }

        return $text;
    }
104889
protected function replaceElement(DOMElement $element)
	{
		$elName = $this->lowercase($element->localName);
		if ($elName === $element->localName)
		{
			return;
		}

		// Create a new element with the correct name
		$newElement = (is_null($element->namespaceURI))
		            ? $this->ownerDocument->createElement($elName)
		            : $this->ownerDocument->createElementNS($element->namespaceURI, $elName);

		// Move every child to the new element
		while ($element->firstChild)
		{
			$newElement->appendChild($element->removeChild($element->firstChild));
		}

		// Copy attributes to the new node
		foreach ($element->attributes as $attribute)
		{
			$newElement->setAttributeNS(
				$attribute->namespaceURI,
				$attribute->nodeName,
				$attribute->value
			);
		}

		// Replace the old element with the new one
		$element->parentNode->replaceChild($newElement, $element);
	}
682366
public static function getDebugTag( $element ) {
		if ( !$element ) {
			return '';
		} elseif ( $element instanceof Element || $element instanceof SerializerNode ) {
			return $element->getDebugTag();
		} else {
			return get_class( $element ) . '#' . substr( md5( spl_object_hash( $element ) ), 0, 8 );
		}
	}
1231685
public function convert(ElementInterface $element)
    {
        $text = trim($element->getValue(), "\t\n\r\0\x0B");

        $href = $element->getAttribute('href');

        $markdown = $text . ' (' . $href . ')';

        $autolink = $this->isValidAutolink((string) $href);

        $href === $text && $autolink && $markdown = $href;

        return $markdown;
    }
1248196
public function render(Element $element)
    {
        // our HTML container
        $html = '';

        // If this is a field, also render our title
        if ($element instanceof AbstractFormField) {
            $html .= '<label>';
            $html .= $element->getTitle();

            // If the field is required, render a red asterisk
            if ($element->isRequired()) {
                $html .= ' <span style="color:red">*</span>';
            }

            $html .= ':</label> ';
        }

        // Now add the default rendering logic to it.
        // This will take care of rendering the rest
        $html .= parent::render($element);

        return $html;
    }
1216297
private function renderElementAsRow(Element $element) : string
    {
        $tr = new Tag('tr');

        $html = $this->renderCell('th', $element->getLabel()->render() . $this->renderErrors($element));
        $html .= $this->renderCell('td', $element->render());

        $tr->setHtmlContent($html);

        return $tr->render();
    }
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;
    }
1000668
public static function toDOM(BaseElement $element): \DOMDocument
    {
        $doc = new \DOMDocument('1.0', 'utf-8');
        $doc->appendChild($element->toDOM($doc));
        return $doc;
    }
730007
public function convert(\DOMElement $parent, TagDescriptor $tag)
    {
        $description = $this->getDescription($tag);

        $child = new \DOMElement('tag');
        $parent->appendChild($child);

        $child->setAttribute('name', str_replace('&', '&amp;', $tag->getName()));
        $child->setAttribute('line', $parent->getAttribute('line'));
        $child->setAttribute('description', str_replace('&', '&amp;', $description));
        $this->addTypes($tag, $child);

        // TODO: make the tests below configurable from the outside so that more could be added using plugins
        if (method_exists($tag, 'getVariableName')) {
            $child->setAttribute('variable', str_replace('&', '&amp;', $tag->getVariableName()));
        }
        if (method_exists($tag, 'getReference')) {
            $child->setAttribute('link', str_replace('&', '&amp;', $tag->getReference()));
        }
        if (method_exists($tag, 'getLink')) {
            $child->setAttribute('link', str_replace('&', '&amp;', $tag->getLink()));
        }
        if (method_exists($tag, 'getMethodName')) {
            $child->setAttribute('method_name', str_replace('&', '&amp;', $tag->getMethodName()));
        }

        return $child;
    }
1135869
protected function extractContentsFromElement($element, array $references = array())
    {
        if ($this->isContentSearchAttribute($element)) {
            $references[] = $element['contentId'];

        } elseif ($this->isEmbeddedContentAttribute($element)) {
            $references[] = $element->getValue()['contentId'];

        } elseif (
            $element instanceof ContentAttributeInterface
            && $element->getType() === 'tinymce'
            && $this->hasInternalLinkBBCode($element->getValue())
        ) {
            $references = array_merge($references, $this->extractContentIdFromBBCode($element->getValue()));

        } elseif (
            is_string($element) &&
            $this->hasInternalLinkBBCode($element)
        ) {
            $references = array_merge($references, $this->extractContentIdFromBBCode($element));

        } elseif (is_array($element)) {
            foreach ($element as $item) {
                $references = array_merge($references, $this->extractContentsFromElement($item));
            }
        }

        return $references;
    }
1104795
protected function transform(DOMDocument $element)
    {
        foreach ($this->transformers as $transformer) {
            $transformer($element);
        }

        return $element;
    }