Parses the message by given an optional HTML view and an optional plain text view
@param string $htmlview
@param string $textview
@return sFire\Mail\Mail
337440
public function render($htmlview = null, $textview = null) {

		if(null !== $htmlview && false === is_string($htmlview)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($htmlview)), E_USER_ERROR);
		}

		if(null !== $textview && false === is_string($textview)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($textview)), E_USER_ERROR);
		}

		$this -> viewmodels = ['html' => $htmlview, 'text' => $textview];

		return $this;
	}
116761
public function parseString($html)
    {
        /** TODO: custom markdown-extra options, e.g. titles & classes **/
        // <sup id="fnref:..."><a href"#fn..." rel="footnote">...</a></sup>
        // => <fnref target="..." />
        $html = preg_replace('@<sup id="fnref:([^"]+)">\s*<a href="#fn:\1" rel="footnote">\s*\d+\s*</a>\s*</sup>@Us', '<fnref target="$1" />', $html);
        // <div class="footnotes">
        // <hr />
        // <ol>
        //
        // <li id="fn:...">...</li>
        // ...
        //
        // </ol>
        // </div>
        // =>
        // <footnotes>
        //   <fn name="...">...</fn>
        //   ...
        // </footnotes>
        $html = preg_replace_callback('#<div class="footnotes">\s*<hr />\s*<ol>\s*(.+)\s*</ol>\s*</div>#Us', [&$this, '_makeFootnotes'], $html);

        return parent::parseString($html);
    }
736129
public function parseInline($text, $whiteList = '', $clearHolders = true, $enableAutoLink = true)
    {
        $self = $this;
        $text = $this->call('beforeParseInline', $text);
        // code
        $text = preg_replace_callback(
            "/(^|[^\\\])(`+)(.+?)\\2/",
            function ($matches) use ($self) {
                return  $matches[1] . $self->makeHolder(
                    '<code>' . htmlspecialchars($matches[3]) . '</code>'
                    );
            },
            $text
            );
        // mathjax
        $text = preg_replace_callback(
            "/(^|[^\\\])(\\$+)(.+?)\\2/",
            function ($matches) use ($self) {
                return  $matches[1] . $self->makeHolder(
                    $matches[2] . htmlspecialchars($matches[3]) . $matches[2]
                    );
            },
            $text
            );
        // escape
        $text = preg_replace_callback(
            "/\\\(.)/u",
            function ($matches) use ($self) {
                $escaped = htmlspecialchars($matches[1]);
                $escaped = str_replace('$', '&dollar;', $escaped);
                return  $self->makeHolder($escaped);
            },
            $text
            );
        // link
        $text = preg_replace_callback(
            "/<(https?:\/\/.+)>/i",
            function ($matches) use ($self) {
                $url = $self->cleanUrl($matches[1]);
                $link = $self->call('parseLink', $matches[1]);
                return $self->makeHolder(
                    "<a href=\"{$url}\">{$link}</a>"
                );
            },
            $text
            );
        // encode unsafe tags
        $text = preg_replace_callback(
            "/<(\/?)([a-z0-9-]+)(\s+[^>]*)?>/i",
            function ($matches) use ($self, $whiteList) {
                if ($self->_html || false !== stripos(
                    '|' . $self->_commonWhiteList . '|' . $whiteList . '|', '|' . $matches[2] . '|'
                    )) {
                        return $self->makeHolder($matches[0]);
                    } else {
                        return htmlspecialchars($matches[0]);
                    }
            },
            $text
            );
        if ($this->_html) {
            $text = preg_replace_callback("/<!\-\-(.*?)\-\->/", function ($matches) use ($self) {
                return $self->makeHolder($matches[0]);
            }, $text);
        }
        $text = str_replace(array('<', '>'),  array('&lt;', '&gt;'),  $text);
        // footnote
        $text = preg_replace_callback(
            "/\[\^((?:[^\]]|\\\\\]|\\\\\[)+?)\]/",
            function ($matches) use ($self) {
                $id = array_search($matches[1], $self->_footnotes);
                if (false === $id) {
                    $id = count($self->_footnotes) + 1;
                    $self->_footnotes[$id] = $self->parseInline($matches[1], '', false);
                }
                return $self->makeHolder(
                    "<sup id=\"fnref-{$id}\"><a href=\"#fn-{$id}\" class=\"footnote-ref\">{$id}</a></sup>"
                );
            },
            $text
            );
        // image
        $text = preg_replace_callback(
            "/!\[((?:[^\]]|\\\\\]|\\\\\[)*?)\]\(((?:[^\)]|\\\\\)|\\\\\()+?)\)/",
            function ($matches) use ($self) {
                $escaped = htmlspecialchars($self->escapeBracket($matches[1]));
                $url = $self->escapeBracket($matches[2]);
                $url = $self->cleanUrl($url);
                return $self->makeHolder(
                    "<img src=\"{$url}\" alt=\"{$escaped}\" title=\"{$escaped}\">"
                );
            },
            $text
            );
        $text = preg_replace_callback(
            "/!\[((?:[^\]]|\\\\\]|\\\\\[)*?)\]\[((?:[^\]]|\\\\\]|\\\\\[)+?)\]/",
            function ($matches) use ($self) {
                $escaped = htmlspecialchars($self->escapeBracket($matches[1]));
                $result = isset( $self->_definitions[$matches[2]] ) ?
                "<img src=\"{$self->_definitions[$matches[2]]}\" alt=\"{$escaped}\" title=\"{$escaped}\">"
                : $escaped;
                return $self->makeHolder($result);
            },
            $text
            );
        // link
        $text = preg_replace_callback(
            "/\[((?:[^\]]|\\\\\]|\\\\\[)+?)\]\(((?:[^\)]|\\\\\)|\\\\\()+?)\)/",
            function ($matches) use ($self) {
                $escaped = $self->parseInline(
                    $self->escapeBracket($matches[1]),  '',  false, false
                    );
                $url = $self->escapeBracket($matches[2]);
                $url = $self->cleanUrl($url);
                return $self->makeHolder("<a href=\"{$url}\">{$escaped}</a>");
            },
            $text
            );
        $text = preg_replace_callback(
            "/\[((?:[^\]]|\\\\\]|\\\\\[)+?)\]\[((?:[^\]]|\\\\\]|\\\\\[)+?)\]/",
            function ($matches) use ($self) {
                $escaped = $self->parseInline(
                    $self->escapeBracket($matches[1]),  '',  false
                    );
                $result = isset( $self->_definitions[$matches[2]] ) ?
                "<a href=\"{$self->_definitions[$matches[2]]}\">{$escaped}</a>"
                : $escaped;
                return $self->makeHolder($result);
            },
            $text
            );
        // strong and em and some fuck
        $text = $this->parseInlineCallback($text);
        $text = preg_replace(
            "/<([_a-z0-9-\.\+]+@[^@]+\.[a-z]{2,})>/i",
            "<a href=\"mailto:\\1\">\\1</a>",
            $text
            );
        // autolink url
        if ($enableAutoLink) {
            $text = preg_replace_callback(
                "/(^|[^\"])((https?):[\p{L}_0-9-\.\/%#!@\?\+=~\|\,&\(\)]+)($|[^\"])/iu",
                function ($matches) use ($self) {
                    $link = $self->call('parseLink', $matches[2]);
                    return "{$matches[1]}<a href=\"{$matches[2]}\">{$link}</a>{$matches[4]}";
                },
                $text
                );
        }
        $text = $this->call('afterParseInlineBeforeRelease', $text);
        $text = $this->releaseHolder($text, $clearHolders);
        $text = $this->call('afterParseInline', $text);
        return $text;
    }
877271
public function plain(string $view, array $data, $callback): Receipt
    {
        return $this->send(['text' => $view], $data, $callback);
    }
421964
public static String getText(TextView view) {
        String text = "";
        if (view != null) {
            text = view.getText().toString();
        } else {
            Log.e("Caffeine", "Null view given to getText().  \"\" will be returned.");
        }
        return text;
    }
1201864
public function parse()
    {
        try {
            $xml       = simplexml_load_string($this->parsedMail->getMessageBody());
        } catch(\Exception $e) {
            $this->warningCount++;

            return $this->failed('XML expected, but got something else. Make sure google is set to send XML based reports!');
        }


        $timestamp = strtotime($xml->attributes()->date);

        foreach ($xml->list as $reports) {
            $this->feedName = (string)$reports->attributes()->type;

            // If feed is known and enabled, validate data and save report
            if ($this->isKnownFeed() && $this->isEnabledFeed()) {
                foreach ($reports->url_info as $url_info) {
                    $url = (string)$url_info->attributes()->url;
                    $ip = (string)$url_info->attributes()->ip;

                    $urlData = getUrlData($url);

                    if (filter_var($ip, FILTER_VALIDATE_IP) === false) {
                        // No IP supplied by Google
                        if (!empty($urlData['host']) &&
                            !filter_var($urlData['host'], FILTER_VALIDATE_IP) === false
                        ) {
                            // Hostname is an IP address
                            $ip = $urlData['host'];
                        } else {
                            // We have no IP address, try to get the IP address by resolving the domain
                            $ip = @gethostbyname($urlData['host']);

                            // If it fails, set to localhost
                            $ip = ($ip == $urlData['host']) ? '127.0.0.1' : $ip;
                        }
                    }

                    $report = [
                        'domain'    => getDomain($url),
                        'uri'       => getUri($url),
                        'category'  => config("{$this->configBase}.feeds.{$this->feedName}.category"),
                    ];

                    // Sanity check
                    if ($this->hasRequiredFields($report) === true) {
                        // incident has all requirements met, filter and add!
                        $report = $this->applyFilters($report);

                        $incident = new Incident();
                        $incident->source      = config("{$this->configBase}.parser.name");
                        $incident->source_id   = false;
                        $incident->ip          = $ip;
                        $incident->domain      = $report['domain'];
                        $incident->class       = config("{$this->configBase}.feeds.{$this->feedName}.class");
                        $incident->type        = config("{$this->configBase}.feeds.{$this->feedName}.type");
                        $incident->timestamp   = $timestamp;
                        $incident->information = json_encode(array_merge($urlData, $report));

                        $this->incidents[] = $incident;
                    }
                }
            }
        }

        return $this->success();
    }
173949
public function createUiComponent(HtmlView $view,
			Eiu $eiu) {
		return $view->getHtmlBuilder()->getEsc(
				implode(self::OUTPUT_SEPARATOR, (array)$eiEntry->getValue(EiPropPath::from($this))));
	}
369801
public function parse(string $html): string
    {
        $html = ltrim($html);
        $this->setTokenPosition($html);

        try {
            $this->name = $this->parseElementName($html);
            $remainingHtml = $this->parseAttributes($html);
            $posOfClosingBracket = $this->getPositionOfElementEndTag($remainingHtml);

            // Is self-closing?
            $posOfSelfClosingBracket = \mb_strpos($remainingHtml, '/>');
            $remainingHtml = \mb_substr($remainingHtml, $posOfClosingBracket + 1);
            if ($posOfSelfClosingBracket !== false && $posOfSelfClosingBracket === $posOfClosingBracket - 1) {
                // Self-closing element. (Note: $this->valuue is unchanged.)
                return $remainingHtml;
            }

            // Lets close those closed-only elements that are left open.
            if (\in_array($this->name, self::VOID_ELEMENTS, true)) {
                return $remainingHtml;
            }

            // Open element.
            return $this->parseContents($remainingHtml);
        } catch (ParseException $e) {
            if ($this->getThrowOnError()) {
                throw $e;
            }
        }

        return '';
    }
792323
public function render($view = null, $data = array())
    {
        if (is_null($view)) {
            $view = static::$defaultView;
        }

        $data = array_merge($data, array(
            'paginator' => $this,
            'elements'  => $this->elements(),
        ));

        return new HtmlString(
            static::viewFactory()->make($view, $data)->render()
        );
    }
244160
private function parseAttributes(string $html): string
    {
        $remainingHtml = \mb_substr($html, mb_strlen($this->name) + 1);
        while (\mb_strpos($remainingHtml, '>') !== false && preg_match("/^\s*[\/]?>/", $remainingHtml) === 0) {
            $remainingHtml = $this->parseAttribute($remainingHtml);
        }

        return $remainingHtml;
    }
256131
public function convertView($view)
    {
        if (strpos($view, '@') !== false || strpos($view, '/') !== false || strpos($view, '\\') !== false) {
            return $view;
        }
        return strtolower(substr(static::className(), strrpos(static::className(), '\\') + 1)) . '-' . $view;
    }
1229459
public function email($address, $text=null, $title=null, $class=null) {
		if (is_null($text)) {
			$text = $address;
		}
		$attributes = $this->getHtmlAttributes(array(
			'title'=>$title,
			'class'=>$class
		));
		return "<a href='mailto:$address'$attributes>$text</a>";
	}
1210607
public function html($html_string=null)
    {
        if ($html_string !== null) { // set html for all nodes
            foreach ($this as $node) {
                $node->get(0)->nodeValue = '';
                $node->append($html_string);
            }

            return $this;
        }
        // get html for first node
        return $this->getInnerHtml();
    }
979683
function parseString($html) {
    $this->parser->html = $html;
    $this->parse();
    return $this->output;
  }
144680
public function sendMail($recipient, $subject, $htmlBody, $textBody = false)
    {
        $message = \Swift_Message::newInstance();
    
        // Subject
        $message->setSubject($subject);
    
        // From
        $fromEmail = $this->configurationManager->getSetting('mailer.sendFrom');
        $fromName = $this->configurationManager->getSetting('mailer.sendFromName');
        $message->setFrom(array($fromEmail => $fromName));
    
        // To
        $message->setTo($recipient);
    
        // HTML body
        $message->setBody($htmlBody, 'text/html');
        
        // Text body
        if ($textBody === false) {
            $textBody = $this->createTextBody($htmlBody);
        }
        $message->addPart($textBody, 'text/plain');
    
        $mailer = $this->getMailer();
        return $mailer->send($message);
    }
243078
@Nullable
    protected View getEmailLabel() {
        final String emailPrompt = dialogConfiguration.emailPrompt();
        if (emailPrompt != null) {
            final TextView labelView = new TextView(this);
            labelView.setText(emailPrompt);
            return labelView;
        }
        return null;
    }
554098
public static function parse($html, $xpath) {
		$doc = new \DOMDocument();
		$doc->loadHTML($html);
		$domxpath = new \DOMXPath($doc);
		$node = $domxpath->evaluate($xpath)->item(0);

		return new static($node);
	}