DebugKit\View\Helper\TidyHelper::tidyErrors PHP Method

tidyErrors() public method

Run the html string through tidy, and return the (raw) errors. pass back a reference to the normalized string so that the error messages can be linked to the line that caused them.
public tidyErrors ( string $in = '', &$out = '' ) : string
$in string ''
return string
    public function tidyErrors($in = '', &$out = '')
    {
        $out = preg_replace('@>\\s*<@s', ">\n<", $in);
        // direct access? windows etc
        if (function_exists('tidy_parse_string')) {
            $tidy = tidy_parse_string($out, [], 'UTF8');
            $tidy->cleanRepair();
            $errors = $tidy->errorBuffer . "\n";
            return $errors;
        }
        // cli
        $File = new File(rtrim(TMP, DS) . DS . rand() . '.html', true);
        $File->write($out);
        $path = $File->pwd();
        $errors = $path . '.err';
        $this->_exec("tidy -eq -utf8 -f {$errors} {$path}");
        $File->delete();
        if (!file_exists($errors)) {
            return '';
        }
        $Error = new File($errors);
        $errors = $Error->read();
        $Error->delete();
        return $errors;
    }