Strip whitespace.

@param string $content The CSS content to strip the whitespace for

@return string
482268
protected function stripWhitespace($content)
    {
        // remove leading & trailing whitespace
        $content = preg_replace('/^\s*/m', '', $content);
        $content = preg_replace('/\s*$/m', '', $content);

        // replace newlines with a single space
        $content = preg_replace('/\s+/', ' ', $content);

        // remove whitespace around meta characters
        // inspired by stackoverflow.com/questions/15195750/minify-compress-css-with-regex
        $content = preg_replace('/\s*([\*$~^|]?+=|[{};,>~]|!important\b)\s*/', '$1', $content);
        $content = preg_replace('/([\[(:>\+])\s+/', '$1', $content);
        $content = preg_replace('/\s+([\]\)>\+])/', '$1', $content);
        $content = preg_replace('/\s+(:)(?![^\}]*\{)/', '$1', $content);

        // whitespace around + and - can only be stripped inside some pseudo-
        // classes, like `:nth-child(3+2n)`
        // not in things like `calc(3px + 2px)`, shorthands like `3px -2px`, or
        // selectors like `div.weird- p`
        $pseudos = array('nth-child', 'nth-last-child', 'nth-last-of-type', 'nth-of-type');
        $content = preg_replace('/:('.implode('|', $pseudos).')\(\s*([+-]?)\s*(.+?)\s*([+-]?)\s*(.*?)\s*\)/', ':$1($2$3$4$5)', $content);

        // remove semicolon/whitespace followed by closing bracket
        $content = str_replace(';}', '}', $content);

        return trim($content);
    }
692401
public function compress($content)
    {
        // Increment recursion level only before doing a compression
        ini_set('pcre.recursion_limit', '16777');

        $content = $this->removeSpaces($content);
        $content = $this->removeComments($content);

        return $content;
    }
890765
private function removeHeaders($content)
        {
            $content = str_replace('<?xml encoding="UTF-8">', "", $content);
            $content = str_replace('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">', "", $content);
            $content = str_replace('<html><body>', "", $content);
            $content = str_replace('</body></html>', "", $content);

            return $content;
        }
25935
public function convert($content)
    {
        $result = strtr($content, $this->rules);
        return $this->correct($result);
    }
1005593
public function sanitizeInput(string $content):string{
		return htmlspecialchars($content, ENT_NOQUOTES | ENT_SUBSTITUTE | ENT_DISALLOWED | ENT_HTML5, 'UTF-8', false);
	}
1032035
public function strip($content)
    {
        $handlers = new HandlerContainer();
        $handlers->setDefault(function(ShortcodeInterface $s) { return $s->getContent(); });
        $processor = new Processor(new RegexParser(), $handlers);

        return $processor->process($content);
    }
889847
private function _html($content) {
        // compress?
        if($this->_config['compress']['html'])
            $content = Algorithms::html($content, $this->_config['config']['html']);

        // return content
        return $content;
    }
192334
private function wrapHeadlinesWithEmptyLines(string $content): string
    {
        return Strings::replace($content, self::HEADLINE_PATTERN, function (array $match) {
            return PHP_EOL . $match['headline'] . PHP_EOL;
        });
    }
1062445
protected function encode($content)
    {
        $jsonString = parent::encode($content);

        if ($this->hasValidCallback()) {
            return \sprintf('%s(%s);', $this->getCallback(), $jsonString);
        }

        return $jsonString;
    }
1254407
protected function formatContent($content)
    {
        $searches = array(
            '{{filename}}',
            '{{namespace}}',
            '{{className}}',
        );

        $replaces = array(
            $this->data['filename'],
            $this->data['namespace'],
            $this->data['className'],
        );

        return str_replace($searches, $replaces, $content);
    }
1183243
protected function toMarkdown($content)
    {
        $tmpfname = tempnam(sys_get_temp_dir(), 'fillet'); // good
        file_put_contents($tmpfname, $content);
        $cmd = $this->config['pandoc']['bin'] . ' --no-wrap -f html -t markdown ' . $tmpfname;
        $content = shell_exec($cmd);
        unlink($tmpfname);
        return $content;
    }
797455
protected function _strip_whitespaces($str)
    {
        $this->filesystem->filePut($this->_tmpLiteFile, $str);
        $str = php_strip_whitespace($this->alias->resolve($this->_tmpLiteFile));
//        $str = preg_replace('#\s*/\*\*.*?\*/#ms', '', $str);//remove comments
//        $str = preg_replace('#([\r\n]+)\s*\\1#', '\\1', $str);//remove blank lines
//        $str = preg_replace('#([\r\n]+)\s+{#', '{', $str);//repositionClose;

        return $str;
    }
571505
protected function shortenBools($content)
    {
        /*
         * 'true' or 'false' could be used as property names (which may be
         * followed by whitespace) - we must not replace those!
         * Since PHP doesn't allow variable-length (to account for the
         * whitespace) lookbehind assertions, I need to capture the leading
         * character and check if it's a `.`
         */
        $callback = function ($match) {
            if (trim($match[1]) === '.') {
                return $match[0];
            }

            return $match[1].($match[2] === 'true' ? '!0' : '!1');
        };
        $content = preg_replace_callback('/(^|.\s*)\b(true|false)\b(?!:)/', $callback, $content);

        // for(;;) is exactly the same as while(true), but shorter :)
        $content = preg_replace('/\bwhile\(!0\){/', 'for(;;){', $content);

        // now make sure we didn't turn any do ... while(true) into do ... for(;;)
        preg_match_all('/\bdo\b/', $content, $dos, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);

        // go backward to make sure positional offsets aren't altered when $content changes
        $dos = array_reverse($dos);
        foreach ($dos as $do) {
            $offsetDo = $do[0][1];

            // find all `while` (now `for`) following `do`: one of those must be
            // associated with the `do` and be turned back into `while`
            preg_match_all('/\bfor\(;;\)/', $content, $whiles, PREG_OFFSET_CAPTURE | PREG_SET_ORDER, $offsetDo);
            foreach ($whiles as $while) {
                $offsetWhile = $while[0][1];

                $open = substr_count($content, '{', $offsetDo, $offsetWhile - $offsetDo);
                $close = substr_count($content, '}', $offsetDo, $offsetWhile - $offsetDo);
                if ($open === $close) {
                    // only restore `while` if amount of `{` and `}` are the same;
                    // otherwise, that `for` isn't associated with this `do`
                    $content = substr_replace($content, 'while(!0)', $offsetWhile, strlen('for(;;)'));
                    break;
                }
            }
        }

        return $content;
    }
626193
public function prepareContent($content)
    {
        if (is_array($content)) {
            $ctt = '';
            foreach ($content as $key=>$ctt) {
                $content .= $ctt;
            }
            $content = $ctt;
        }
        $_escaped_output = strip_tags((string) $content);
        if ($_escaped_output != (string) $content) {
            if (preg_match('/(.*)<body(.*)</body>/i', (string) $content, $matches)) {
                $_output = $matches[0];
            } else {
                $_output = (string) $content;
            }
            $content = Html2Text::convert($_output);
        }
        return (string) $content;
    }
1127259
public static function stripUnicodeRanges($content)
    {
        foreach (self::$stripUnicodeRanges as $range) {
            $content = self::stripUnicodeRange($content, $range[0], $range[1]);
        }

        return $content;
    }
1357879
protected function includeExpr($content)
    {
        try {
            $pattern = '/<!--#if([\s\t]?)expr="([^"]*)"([\s\t]?)-->([^"]*)<!--#endif-->/sU';
            $content = preg_replace($pattern, '', $content);
            return $content;
        } catch (\Exception $e) {
            $this->error(500);
        }
    }
755869
public function parseLogBody($content)
    {
        $pattern      = "/^".self::STACK_TRACE_DIVIDER_PATTERN."/m";
        $parts        = array_map('ltrim', preg_split($pattern, $content));
        $context      = $parts[0];
        $stack_traces = (isset($parts[1])) ? $parts[1] : null;

        return compact('context', 'stack_traces');
    }