Handle html when resulting html is requested

@param string $html

@return string
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;
    }
233870
public function transform($html)
    {
        if (class_exists('HTMLPurifier')) {
            $config = HTMLPurifier_Config::createDefault();
            $purifier = new HTMLPurifier($config);
            $cleanHtml = $purifier->purify($html);
        } else {
            $cleanHtml = strip_tags($html, '<a><b><br><i><p><s><u>');
        }

        return $cleanHtml;
    }
1190660
public static function htmlToPlainText($html)
    {
        // Replace &nbsp; with spaces
        $html = str_replace("\xC2\xA0", ' ', html_entity_decode($html));
        // Strip out HTML tags
        $text = strip_tags($html);
        // Replace excessive whitespace (spaces, tabs, and line breaks) with single space
        $text = preg_replace('/\s+/S', ' ', $text);

        return $text;
    }
218713
public function parseHtml($html)
    {
        return Parser::table($html, '#DBGrid', [
            'status', 'name', 'credit', 'examination', 'property', 'teacher', 'code', 'week',
            ['hour', function (Crawler $crawler) {
                return $crawler->attr("title") ?: $crawler->text();
            }],
            ['place', function (Crawler $crawler) {
                return $crawler->text() == ";" ? '' : ($crawler->attr("title") ?: $crawler->text());
            }],
            'campus',
            ['class', function (Crawler $crawler) {
                return $crawler->attr("title") ?: $crawler->text();
            }],
        ], 12, 1, 'text');
    }
589241
protected static function mPDFWrapper($html)
    {
        $pdf = new \Mpdf\Mpdf();
        $pdf->WriteHTML($html);

        return $pdf->Output('','S');    // returns the PDF as a string
    }
874871
public function setHtml($html = null)
    {
        $html = trim($html);
        $this->html = 0 < strlen($html) ? $html : null;

        return $this;
    }
1005359
public function convertToString($html)
    {
        $extractedStylesheets = $this->extractExternalStylesheets($html);
        $links = $this->createStylesheetPaths($extractedStylesheets['links']);

        $externalStylesheets =  array(
            'tags' => $extractedStylesheets[0],
            'links' => $links
        );

        $html = $this->replaceExternalCss($html, $externalStylesheets);

        return $html;
    }
700342
private function cleanupXss($html)
    {
        if (false === $this->config['xss_filter']) {
            return $html;
        }

        $this->logger->info('Filtering HTML to remove XSS');

        return htmLawed(
            $html,
            [
                'safe' => 1,
                // *+iframe: do not remove iframe elements
                'elements' => '*+iframe-meta',
                'deny_attribute' => 'style',
                'comment' => 1,
                'cdata' => 1,
            ]
        );
    }
300659
public function html2text($html)
    {
        if (!$this->html2textLoaded) {
            require dirname(__FILE__).'/../Utility/Html2Text.php';
            $this->html2textLoaded = true;
        }
        $html2text = new Html2Text($html);

        return $html2text->get_text();
    }
8149
public function loadHtml($html)
    {
        if (!is_string($html)) {
            throw new InvalidArgumentException(__METHOD__ . ' expects parameter 1 to be string.');
        }

        libxml_use_internal_errors(true);
        libxml_disable_entity_loader(true);

        $sxe = simplexml_load_string($html);
        if (libxml_get_errors()) {
            $this->document->loadHTML('<?xml encoding="UTF-8">' . $html);
        } else {
            $this->document = dom_import_simplexml($sxe)->ownerDocument;
        }

        libxml_clear_errors();
        libxml_disable_entity_loader(false);
        libxml_use_internal_errors(false);

        return $this;
    }
1076786
public function plain($html)
    {
        $plain = preg_replace('#<br\s*/?>#iu', "\n", $html);
        $plain = strip_tags($plain);
        $plain = html_entity_decode($plain, ENT_QUOTES | ENT_HTML5);

        return $plain;
    }
1314865
private function minifyHTML($html)
    {
        $search = array('/(?:(?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:(?<!\:|\\\|\'|\")\/\/.*))/', '/\n/', '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s', '/<!--.*?-->/');
        $replace = array(' ', ' ', '>', '<', '\\1', '');

        $squeezedHTML = preg_replace($search, $replace, $html);

        return $squeezedHTML;

    }
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);
    }
1188414
public function convertToString($html)
    {
        $externalJavaScript = $this->extractExternalJavaScript($html);

        return $this->replaceJavaScriptTags($html, $externalJavaScript);
    }
1065706
public function parseContent( $html ){
		$pattern = '~<p>ADDTEMPLATE\(([\w_:-]*)\):([\w_-]+):ETALPMETDDA<\/p>~m';
		if( preg_match_all($pattern, $html, $matches, PREG_SET_ORDER) ){
			foreach($matches as $match){
				//if a zone is specified, attach the template
				if(!empty($match[1])){
					$this->getLayout()->addTemplateTo($match[1], $match[2]);
					$html = str_replace($match[0], '', $html);
				}else{
				//otherwise inject the template inline into the wikitext
					$html = str_replace($match[0], $this->getLayout()->renderTemplate($match[2]), $html);
				}
			}
		}
		return $html;
	}
33994
public static function Html($html): string
    {
        // Remove newlines, tabs, zero
        $html = str_replace(["\0", "\t", "\r"], '', $html);

        // Remove spaces
        while (strpos($html, '  ') !== false) {
            $html = str_replace('  ', ' ', $html);
        }

        // Remove spaces after new lines
        $html = str_replace("\n ", "\n", $html);

        // Can optimize only without textarea, because in have to keep formatting
        $textarea = strpos($html, '<textarea');
        if ($textarea !== false) {
            // Remove double newlines
            while (strpos($html, "\n\n") !== false) {
                $html = str_replace("\n\n", "\n", $html);
            }
        }

        $fl = substr($html, 0, strpos($html, "\n")); // First line
        if (stripos($fl, 'strict') === false && substr($fl, 0, 5) !== '<?xml') {
            $html = str_replace('/>', '>', $html);
            if ($textarea === false) {
                $html = preg_replace('/([a-zA-Z0-9]+="[^"]+") /', '\\1', $html);
            }
        }
        $html = str_replace([' />'], ['/>'], $html);

        if ($textarea === false) {
            $html = str_replace("\n", '', $html);
        }

        return $html;
    }
1204104
public function get($html) {
      $kernel_dir = $this->kerneldir;
      require __DIR__ . "/../Resources/config/dompdf.php";

      $this->pdf = new DOMPDF;

      foreach ($this->options as $optionKey => $optionValue) {
         $this->pdf->set_option($optionKey, $optionValue);
      }

      $this->pdf->load_html($html);
      $this->pdf->set_paper("a4", 'portrait');
      $this->pdf->render();

      $response = new Response();

      $response->setContent($this->pdf->output());
      $response->setStatusCode(200);
      $response->headers->set('Content-Type', 'application/pdf');

      return $response;
   }