code = ''; $this->gitCodeRaw = $this->getCodeFromGit(); $this->gitCode = (iconv('TIS-620', 'UTF-8', $this->gitCodeRaw)); $this->diffResult = ''; } public function compare() { try { $this->gitCodeRaw = $this->getCodeFromGit(); $this->gitCode = (iconv('TIS-620', 'UTF-8', $this->gitCodeRaw)); $this->comparisonResult = 'GitLab connection successful.'; $this->diffResult = $this->getDiff($this->gitCode, $this->code); // dd($this->diffResult); $this->emit('diffResultUpdated'); } catch (RequestException $e) { $this->comparisonResult = 'Error connecting to GitLab: ' . $e->getMessage(); $this->gitCode = ''; $this->gitCodeRaw = ''; } } public function getDiff($code1, $code2) { $diffOptions = [ 'context' => 0, 'ignoreCase' => false, 'ignoreWhitespace' => true, ]; $rendererOptions = [ 'detailLevel' => 'char', 'language' => 'eng', 'lineNumbers' => true, 'separateBlock' => true, 'showHeader' => true, 'spacesToNbsp' => false, 'outputFormat' => 'inline', 'mergeThreshold' => 0.8, 'originalFileName' => 'Original', 'newFileName' => 'New', 'cliColorization' => 'none', ]; $differ = new Differ(explode("\n", $code1), explode("\n", $code2), $diffOptions); $renderer = RendererFactory::make('Inline', $rendererOptions); $result = $renderer->render($differ); $result = $this->convertDiffToPrismFormat($result); return $result; } private function convertDiffToPrismFormat($diffHtml) { $diffHtml = str_replace('