diff = $d; parent::__construct(); } public function _blockHeader($xbeg, $xlen, $ybeg, $ylen) { $removed = $xlen - $ylen; if ($removed > 0) { return 'Line '.$xbeg.' (now '.$ybeg.'), was '.$xlen.' lines, now '.$ylen.' lines'; } } public function _added($lines) { self::escapeHTML($lines); return ' '.implode(''."\n".' ', $lines).''; } public function _context($lines) { self::escapeHTML($lines); return "\n" . parent::_context($lines); } public function _deleted($lines) { self::escapeHTML($lines); return ' '.implode(''."\n".' ', $lines).''; } public function _changed($orig, $final) { return $this->_deleted($orig)."\n".$this->_added($final); } public function render($diff) { return parent::render($this->diff); } protected static function escapeHTML(&$lines) { array_walk($lines, function(&$a, $b) { $a = htmlspecialchars($a); }); } }