Parses HTML for headings.
@access		public
@param		string		$html		Reference to HTML to inspect for headings
@return		void
778082
public function importFromHtml( &$content, $level = 1 ){
		$this->headings	= array();																	//  
		$this->tree		= $this->importFromHtmlRecursive( $content, $level );						//  
		$this->setHeadingIds( $content, $level );													//  
	}
455537
private function _parse()
    {
        $this->contentXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->contentXml);
        $this->stylesXml  = str_replace(array_keys($this->vars), array_values($this->vars), $this->stylesXml);
    }
295391
public function parseXml($node)
    {
        foreach ($node->childNodes as $item) {
            if ($item->nodeName != "#text") {
                $this->set( $item->nodeName, $item->nodeValue);
            }
        }

    }
1011219
protected function parse( $url ) {

		$helper = new HtmlDomParserHelper();
		$parser = $helper->parse($url);

		$nodes = $parser->find('sitemap loc');

		if( !empty($nodes) ) {

			foreach( $nodes as $node ) {

				$this->sitemaps[] = $node->innertext;
			}
		}

		$nodes = $parser->find('url');

		if( !empty($nodes) ) {

			foreach( $nodes as $node ) {

				$loc = $node->find('loc', 0);

				if( !isset($this->urls[$loc->innertext]) ) {

					$url = new SitemapUrl();

					// Set url
					$url->setUrl($loc->innertext);

					// Find alternate links
					$alternateLinks = $node->find('xhtml:link[rel=alternate]');

					foreach($alternateLinks as $alternateLink) {

						$url->addAlternateLinks($alternateLink->getAttribute('hreflang'), $alternateLink->getAttribute('href'));
					}

					// Push in array
					$this->urls[$url->getUrl()] = $url;
				}
			}
		}

		$helper->clear();
	}
592561
private function parseNoContents(string $tag, string $html): string
    {
        $remainingHtml = \ltrim($html);
        $matchingResult = \preg_match(
            "/(<\/\s*" . $tag . "\s*>)/i",
            $html,
            $endOfScriptMatches
        );
        if ($matchingResult === 0) {
            return '';
        }

        $closingTag = $endOfScriptMatches[1];
        $this->value = \mb_substr($remainingHtml, 0, \mb_strpos($html, $closingTag));

        return \mb_substr(
            \mb_strstr($remainingHtml, $closingTag),
            \mb_strlen($closingTag)
        );
    }
333854
private function handleHtmlResult($html)
    {
        if ($this->preserve_no_newlines) {
            $html = str_replace("\n", '', $html);
        }
        if (stripos($html, 'dqn_tmp_id=') !== false) {
            $html = preg_replace('/ dqn_tmp_id="([a-z0-9]+)"/', '', $html);
        }

        return $html;
    }
538135
public function convert($html)
    {
        $html = parent::convert((string) $html);

        $html = $this->encode('--', '-', $html, false);
        $html = $this->encode('\#', '#', $html);
        $html = $this->encode('\*', '*', $html);
        $html = $this->encode('\_', '_', $html);
        $html = $this->encode('•', '*', $html);
        $html = $this->encode('…', '...', $html);

        $html = $this->encode('\[', '[', (string) $html);
        $html = $this->encode('\]', ']', (string) $html);
        $html = str_replace(array('—', '–', '\-'), '-', $html);
        $html = str_replace(array('“', '”'), '"', $html);
        $html = str_replace(array('’', '‘'), "'", $html);
        $html = str_replace("\n\n\n", "\n\n", $html);
        $html = str_replace("\n ", "\n", (string) $html);

        return str_replace('\.', '.', (string) $html);
    }
1361206
public function html($code)
    {
        if ($this->sdopx->parsingType == Sdopx::PARSING_SQL) {
            if ($code != '') {
                if (trim($code) == '') {
                    $this->output[] = ' ';
                    return;
                } else {
                    if (preg_match('@^\s+([\w\W]+)\s+$@', $code, $mt)) {
                        $this->output[] = ' ' . trim($mt[1]) . ' ';
                    } else if (preg_match('@^\s+([\w\W]+)$@', $code, $mt)) {
                        $this->output[] = ' ' . trim($mt[1]);
                    } else if (preg_match('@^([\w\W]+)\s+$@', $code, $mt)) {
                        $this->output[] = trim($mt[1]) . ' ';
                    } else {
                        $this->output[] = $code;
                    }
                    return;
                }
            }
            return;
        }
        $this->output[] = $code;
    }
714490
public function writeHTML($html)
    {
        $html = $this->parsingHtml->prepareHtml($html);
        $html = $this->parsingCss->extractStyle($html);
        $this->parsingHtml->parse($this->lexer->tokenize($html));
        $this->_makeHTMLcode();

        return $this;
    }
1282640
public function setHtml($Html)
    {
        if (! is_object($Html) || ! $Html instanceof HtmlObject) {
            throw new \InvalidArgumentException(
                'The HTML Object must be a valid HTML Object'
            );
        }
        $this->Html = $Html;

        return true;
    }
1353265
public function get($html = null)
    {
        if (null === $html) {
            if (file_exists($this->_path)) {
                $html = file_get_contents($this->_path);
            }
        }

        $this->_path = null;

        return $this->parse($html);
    }
496516
public function info($html)
    {
        $tags = array('{total}', '{start}', '{end}', '{page}', '{pages}');
        $code = array($this->total, $this->start() + 1, $this->end(), $this->get, $this->pages());

        return str_replace($tags, $code, $html);
    }
786940
protected static function processSetLayout($html){
    $pattern = '~<p>LAYOUT:([\w_-]+):TUOYAL<\/p>~m';
    if( preg_match_all($pattern, $html, $matches, PREG_SET_ORDER) ){
      $layout = array_pop($matches);

      self::setLayout($layout[1]);

      $html = preg_replace($pattern, '', $html);
    }
    return $html;
  }
1135243
public function parse($headers)
    {
        $lines = preg_split("/(\r|\n)+/", $headers, -1, PREG_SPLIT_NO_EMPTY);
        array_shift($lines);

        foreach ($lines as $line) {
            list($name, $value) = explode(':', $line, 2);
            $this->{strtolower(trim($name))} = trim($value);
        }
    }
20158
protected function _parseTags(&$text)
    {
        $replace = array();
        $matches = array();

        // <ktml:block extend|prepend|replace="[name]"></khtml:block>
        if(preg_match_all('#<ktml:block\s+(extend|prepend|replace)="([^"]+)"(.*)>(.*)</ktml:block>#siU', $text, $matches))
        {
            $count = count($matches[0]);

            for($i = 0; $i < $count; $i++)
            {
                $name = $matches[2][$i];

                //Create attributes array
                $defaults = array(
                    'title'   => '',
                    'extend'  => ''
                );

                $attributes = array_merge($defaults, $this->parseAttributes($matches[3][$i]));

                //Create block
                $block = array(
                    'content'  => $matches[4][$i],
                    'title'    => $attributes['title'],
                    'extend'   => $matches[1][$i],
                    'attribs'  => (array) array_diff_key($attributes, $defaults)
                );

                //Clear any prior added blocks
                if($block['extend'] == 'replace') {
                    $this->clearBlocks($name);
                }

                $this->addBlock($name, $block);

                //Do not continue adding blocks
                if($block['extend'] == 'replace') {
                    break;
                }
            }

            //Remove the tags
            $text = str_replace($matches[0], '', $text);
        }

        // <ktml:block name="[name]" condition="[condition]"></khtml:block>
        if(preg_match_all('#<ktml:block\s+name="([^"]+)"(.*"[^"]*")?>(.*)</ktml:block>#siU', $text, $matches))
        {
            $count = count($matches[1]);

            for($i = 0; $i < $count; $i++)
            {
                $name = $matches[1][$i];

                if($this->hasBlocks($name))
                {
                    $attribs     = $this->parseAttributes( $matches[2][$i] );
                    $replace[$i] = '';

                    if(isset($attribs['condition']))
                    {
                        if($this->_countBlocks($attribs['condition']))
                        {
                            unset($attribs['condition']);
                            $replace[$i] = $this->_renderBlocks($name, $attribs);
                        }
                    }
                    else $replace[$i] = $this->_renderBlocks($name, $attribs);

                    if(!empty($replace[$i])) {
                        $replace[$i] = str_replace('<ktml:block:content>', $replace[$i], $matches[3][$i]);
                    }
                }
            }

            $text = str_replace($matches[0], $replace, $text);
        }

        $replace = array();
        $matches = array();
        // <ktml:block name="[name]" condition="[condition]" />
        if(preg_match_all('#<ktml:block\s+name="([^"]+)"(.*"[^"]*")?\s+\/>#siU', $text, $matches))
        {
            $count = count($matches[1]);

            for($i = 0; $i < $count; $i++)
            {
                $name = $matches[1][$i];

                if($this->hasBlocks($name))
                {
                    $attribs     = $this->parseAttributes( $matches[2][$i]);
                    $replace[$i] = '';

                    if(isset($attribs['condition']))
                    {
                        if($this->_countBlocks($attribs['condition']))
                        {
                            unset($attribs['condition']);
                            $replace[$i] = $this->_renderBlocks($name, $attribs);
                        }
                    }
                    else $replace[$i] = $this->_renderBlocks($name, $attribs);

                }
            }

            $text = str_replace($matches[0], $replace, $text);
        }
    }
1018587
protected function getHeadFrag($html)
    {
        if (!($html = (string) $html)) {
            return []; // Nothing to do.
        }
        if (preg_match('/(?P<all>(?P<open_tag>\<head(?:\s+[^>]*?)?\>)(?P<contents>.*?)(?P<closing_tag>\<\/head\>))/uis', $html, $head_frag)) {
            return $this->removeNumericKeysDeep($head_frag);
        }
        return [];
    }
778967
public function parse($html)
    {
        $errorHandling = libxml_use_internal_errors(true);

        $dom = new \DOMDocument();
        $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);

        $xpath = new \DOMXpath($dom);

        foreach ($this->componentFactories as $tag => $factory) {
            $tags = $xpath->query('//' . $tag);

            if ($tags) {
                foreach ($tags as $node) {
                    $factory->parse($node);
                }
            }
        }

        libxml_clear_errors();
        libxml_use_internal_errors($errorHandling);

        return $dom->saveHTML();
    }