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

process() public method

Return a nested array of errors for the passed html string Fudge the markup slightly so that the tag which is invalid is highlighted
public process ( string $html = '', &$out = '' ) : array
$html string ''
return array
    public function process($html = '', &$out = '')
    {
        $errors = $this->tidyErrors($html, $out);
        if (!$errors) {
            return [];
        }
        $result = ['Error' => [], 'Warning' => [], 'Misc' => []];
        $errors = explode("\n", $errors);
        $markup = explode("\n", $out);
        foreach ($errors as $error) {
            preg_match('@line (\\d+) column (\\d+) - (\\w+): (.*)@', $error, $matches);
            if ($matches) {
                list($original, $line, $column, $type, $message) = $matches;
                $line = $line - 1;
                $string = '</strong>';
                if (isset($markup[$line - 1])) {
                    $string .= h($markup[$line - 1]);
                }
                $string .= '<strong>' . h(@$markup[$line]) . '</strong>';
                if (isset($markup[$line + 1])) {
                    $string .= h($markup[$line + 1]);
                }
                $string .= '</strong>';
                $result[$type][$string][] = h($message);
            } elseif ($error) {
                $message = $error;
                $result['Misc'][h($message)][] = h($message);
            }
        }
        $this->results = $result;
        return $result;
    }